本文整理汇总了C#中IRunnable.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IRunnable.Select方法的具体用法?C# IRunnable.Select怎么用?C# IRunnable.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRunnable
的用法示例。
在下文中一共展示了IRunnable.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunSimulation
private void RunSimulation()
{
var hitCounterChannel = new Channel<bool>(10000);
ITokenParser parser = CreateTokenParser(hitCounterChannel);
var requestChannel = new Channel<string>(10000);
var statsChannel = new Channel<long>(10000);
var actors =
new IRunnable[] {new RequestSource(requestChannel)}
.Concat(
Enumerable.Range(0, Parameters.NumRequestProcessors)
.Select(n => new RequestProcessor(requestChannel, statsChannel, parser)))
.ToList();
var stats = new StatsProcessor(statsChannel);
var statsTask = stats.RunAsync();
var hitCounter = new HitCounter(hitCounterChannel);
var hitCounterTask = hitCounter.RunAsync();
var actorTasks = actors.Select(a => a.RunAsync()).ToArray();
Console.WriteLine("Waiting for simulation to complete");
Task.WaitAll(actorTasks);
Console.WriteLine("Simulation completed");
statsChannel.Close();
hitCounterChannel.Close();
Task.WaitAll(statsTask, hitCounterTask);
Console.WriteLine("Number of Messages: {0}", stats.Count);
Console.WriteLine("Min Processing Time: {0} ms", stats.Min);
Console.WriteLine("Average processing time: {0}", stats.Mean);
Console.WriteLine("Max Processing Time: {0} ms", stats.Max);
Console.WriteLine("Standard Deviation: {0}", stats.StandardDeviation);
Console.WriteLine("Cache Hit Rate: {0} ({1} of {2} requests)",
hitCounter.HitRate, hitCounter.TotalHits, hitCounter.TotalRequests);
Console.WriteLine();
Console.WriteLine("Min,Mean,Max,Std.Dev,HitRate,TotalHits,TotalRequests");
Console.WriteLine("{0},{1},{2},{3},{4},{5},{6}",
stats.Min, stats.Mean, stats.Max, stats.StandardDeviation,
hitCounter.HitRate,hitCounter.TotalHits, hitCounter.TotalRequests);
}