本文整理汇总了C#中ICollection.LongCount方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.LongCount方法的具体用法?C# ICollection.LongCount怎么用?C# ICollection.LongCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.LongCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreEachDataTableTwoTimesAsync
static void StoreEachDataTableTwoTimesAsync(ICollection<DataTable> tables, int iteration)
{
Console.WriteLine(); // Spacer
Console.WriteLine(@"Storing each data table (two times, asynchronously), iteration {0}...", iteration);
var stopwatch = new Stopwatch();
stopwatch.Start();
var tasks = new List<Task>();
foreach (var table in tables)
{
tasks.Add(TaskHelper.RunAsync(() => PersistentCache.DefaultInstance.AddStaticToDefaultPartition(table.TableName, table)));
}
foreach (var table in tables)
{
tasks.Add(TaskHelper.RunAsync(() => PersistentCache.DefaultInstance.AddStaticToDefaultPartition(table.TableName, table)));
}
foreach (var task in tasks)
{
task.Wait();
}
stopwatch.Stop();
Debug.Assert(PersistentCache.DefaultInstance.Count() == tables.Count);
Debug.Assert(PersistentCache.DefaultInstance.LongCount() == tables.LongCount());
Console.WriteLine(@"Data tables stored in: {0}", stopwatch.Elapsed);
Console.WriteLine(@"Current cache size: {0} MB", PersistentCache.DefaultInstance.CacheSizeInKB() / 1024L);
Console.WriteLine(@"Approximate speed (MB/sec): {0:.0}", _tableListSize * 2 / stopwatch.Elapsed.TotalSeconds);
}
示例2: StoreAndRetrieveEachDataTableAsync_Volatile
static void StoreAndRetrieveEachDataTableAsync_Volatile(ICollection<DataTable> tables, int iteration)
{
Console.WriteLine(); // Spacer
Console.WriteLine(@"[Volatile] Storing and retrieving each data table asynchronously, iteration {0}...", iteration);
var stopwatch = new Stopwatch();
stopwatch.Start();
var writeTasks = new List<Task>();
foreach (var table in tables)
{
writeTasks.Add(TaskHelper.RunAsync(() => VolatileCache.DefaultInstance.AddStaticToDefaultPartition(table.TableName, table)));
}
var readTasks = new List<Task<Option<DataTable>>>();
foreach (var table in tables)
{
var localTable = table;
readTasks.Add(Task.Factory.StartNew(() => VolatileCache.DefaultInstance.GetFromDefaultPartition<DataTable>(localTable.TableName)));
}
foreach (var task in writeTasks)
{
task.Wait();
}
foreach (var task in readTasks)
{
task.Wait();
}
stopwatch.Stop();
Debug.Assert(VolatileCache.DefaultInstance.Count() == tables.Count);
Debug.Assert(VolatileCache.DefaultInstance.LongCount() == tables.LongCount());
Console.WriteLine(@"[Volatile] Data tables stored and retrieved in: {0}", stopwatch.Elapsed);
Console.WriteLine(@"[Volatile] Current cache size: {0} MB", VolatileCache.DefaultInstance.CacheSizeInKB() / 1024L);
Console.WriteLine(@"[Volatile] Approximate speed (MB/sec): {0:.0}", _tableListSize * 2 / stopwatch.Elapsed.TotalSeconds);
}
示例3: StoreEachDataTable_Memory
static void StoreEachDataTable_Memory(ICollection<DataTable> tables, int iteration)
{
Console.WriteLine(); // Spacer
Console.WriteLine(@"[Memory] Storing each data table, iteration {0}...", iteration);
var stopwatch = new Stopwatch();
stopwatch.Start();
foreach (var table in tables)
{
MemoryCache.DefaultInstance.AddStaticToDefaultPartition(table.TableName, table);
}
stopwatch.Stop();
Debug.Assert(MemoryCache.DefaultInstance.Count() == tables.Count);
Debug.Assert(MemoryCache.DefaultInstance.LongCount() == tables.LongCount());
Console.WriteLine(@"[Memory] Data tables stored in: {0}", stopwatch.Elapsed);
Console.WriteLine(@"[Memory] Current cache size: {0} MB", MemoryCache.DefaultInstance.CacheSizeInKB() / 1024L);
Console.WriteLine(@"[Memory] Approximate speed (MB/sec): {0:.0}", _tableListSize / stopwatch.Elapsed.TotalSeconds);
}