本文整理汇总了C#中Stopwatch.ElapsedMicroseconds方法的典型用法代码示例。如果您正苦于以下问题:C# Stopwatch.ElapsedMicroseconds方法的具体用法?C# Stopwatch.ElapsedMicroseconds怎么用?C# Stopwatch.ElapsedMicroseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.ElapsedMicroseconds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelayMicroSeconds
public static void DelayMicroSeconds(int ms)
{
var sw = new Stopwatch();
sw.Start();
while (sw.ElapsedMicroseconds() < ms)
{
continue;
}
}
示例2: is_copy_slower_for_big_arrays
public void is_copy_slower_for_big_arrays()
{
var gen2Gc = GC.CollectionCount(2);
var smallArray = new ArraySegment<byte>[1024];
var bigArray = new ArraySegment<byte>[1024*64];
var destinationArray = new ArraySegment<byte>[512];
//warmup
var batchSize = 100000;
for (int i = 0; i < batchSize; i++)
{
Array.Copy(smallArray, 512, destinationArray, 0, 512);
Array.Copy(bigArray, 512, destinationArray, 0, 512);
}
var watch = new Stopwatch();
watch.Start();
for (int i = 0; i < batchSize; i++)
{
Array.Copy(smallArray,512,destinationArray,0,512);
}
watch.Stop();
Console.WriteLine(string.Format("small copy us {0}", watch.ElapsedMicroseconds()) );
watch = new Stopwatch();
watch.Start();
for (int i = 0; i < batchSize; i++)
{
Array.Copy(bigArray, 2048, destinationArray, 0, 512);
}
watch.Stop();
Console.WriteLine(string.Format("big copy us {0}", watch.ElapsedMicroseconds()));
gen2Gc = GC.CollectionCount(2) - gen2Gc;
Console.WriteLine(gen2Gc);
}