本文整理汇总了C#中Stopwatch.GetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C# Stopwatch.GetSpeed方法的具体用法?C# Stopwatch.GetSpeed怎么用?C# Stopwatch.GetSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.GetSpeed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Example
private static void Example(int tickCount, KeysType keysType)
{
Stopwatch sw = new Stopwatch();
const string FILE_NAME = "test.stsdb4";
File.Delete(FILE_NAME);
//insert
Console.WriteLine("Inserting...");
sw.Reset();
sw.Start();
int c = 0;
using (IStorageEngine engine = STSdb.FromFile(FILE_NAME))
{
ITable<long, Tick> table = engine.OpenXTable<long, Tick>("table");
foreach (var kv in TicksGenerator.GetFlow(tickCount, keysType)) //generate random records
{
table[kv.Key] = kv.Value;
c++;
if (c % 100000 == 0)
Console.WriteLine("Inserted {0} records", c);
}
engine.Commit();
}
sw.Stop();
Console.WriteLine("Insert speed:{0} rec/sec", sw.GetSpeed(tickCount));
//read
Console.WriteLine("Reading...");
sw.Reset();
sw.Start();
c = 0;
using (IStorageEngine engine = STSdb.FromFile(FILE_NAME))
{
ITable<long, Tick> table = engine.OpenXTable<long, Tick>("table");
foreach (var row in table) //table.Forward(), table.Backward()
{
//Console.WriteLine("{0} {1}", row.Key, row.Value);
c++;
if (c % 100000 == 0)
Console.WriteLine("Read {0} records", c);
}
}
sw.Stop();
Console.WriteLine("Read speed:{0} records", sw.GetSpeed(c));
}