По-русски

harpywar.com

The main

Wiki

Forums

Laboratory

Need For Kill

PvPGN

Github

 Projects
   QDoom
   IRC Search
   vbreality [web]
   UTech p2p Realm [web]
   PvPGN Statistics System
   Diablo 2 Launcher
   WoW Simple Launcher

 Mine
   Creation
   Equipment

 Items
   Games
   Servers tooling
     PvPGN
     D2GS
     NFS: U
     Apache
     ArcEmu

   Coding
     .NET
     PHP

   Miscellaneous

Search on site


Хостинг и VDS, скидка при переходе
 
VB.NET ↔ C# compare
Measuring run-time code
InputBox in C#
Get Assembly Version at runtime
Measuring run-time codeCreated: 24.02.2010
Edited: 24.02.2010
Author: HarpyWar

Sorry, this item isn't translated yet.

You can read it in russian or try google translate.

Stranger06 Август 2010, 08:39 | #282 
Наиболее точное измерение можно получить через апишные функции
using System;

namespace PerfCounter {

/// <summary>
/// Этот класс предоставляет "секундомер" для приложений,
/// требующих точного измерения времени
/// </summary>
public class Counter
{

[System.Runtime.InteropServices.DllImport("KERNEL32")]
private static extern bool QueryPerformanceCounter(ref
long lpPerformanceCount);

[System.Runtime.InteropServices.DllImport("KERNEL32")]
private static extern bool
QueryPerformanceFrequency(ref long lpFrequency);

long totalCount = 0;
long startCount = 0;
long stopCount = 0;
long freq = 0;

public void Start()
{
startCount = 0;
QueryPerformanceCounter(ref startCount);
}

public void Stop()
{
stopCount = 0;
QueryPerformanceCounter(ref stopCount);
totalCount += stopCount - startCount;
}

public void Reset()
{
totalCount = 0;
}

public float TotalSeconds
{
get
{
freq = 0;
QueryPerformanceFrequency(ref freq);
return((float) totalCount / (float) freq);
}
}

public double MFlops(double total_flops)
{
return (total_flops / (1e6 * TotalSeconds));
}

public override string ToString()
{
return String.Format("{0:F3} seconds", TotalSeconds);
}
}
}

см. http://www.microsoft.com/Rus/Msdn/Magazine/2004/03/ScienceComputing.mspx

HarpyWar06 Август 2010, 12:15 | #283 
Для QueryPerformanceCounter существует баг, в котором счетчик может прыгнуть вперед вплоть до нескольких секунд. А GetTickCount правильный, но там точность до миллисекунд.
http://support.microsoft.com/kb/274323

Хотя, не знаю, как с этим в Stopwatch, в документации об этом не написано.

basman26 Декабрь 2013, 16:41 | #366 
Stopwatch работает с апи функциями QueryPerformanceCounter и QueryPerformanceFrequency
зачем ты велосипед сделал? :)


Есть вопросы по настройке игровых серверов? Добро пожаловать на форум!

Name: Verify: = 1950


© 2006—2014, HarpyWar

Any copying information from this site only with reference to the source.
This equally applies to any copyright information in the Internet.