本文整理汇总了C#中ConcurrentQueue.Max方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentQueue.Max方法的具体用法?C# ConcurrentQueue.Max怎么用?C# ConcurrentQueue.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentQueue
的用法示例。
在下文中一共展示了ConcurrentQueue.Max方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTest
public void RunTest(bool enableSnapshotting, int numberOfCommandsToProcess)
{
var handleTimes = new ConcurrentQueue<DispatchStats>();
var viewManager = CreateViewManager();
var commandProcessor = CreateCommandProcessor(enableSnapshotting, viewManager, handleTimes);
var stopwatch = Stopwatch.StartNew();
var lastResult = Enumerable.Range(0, numberOfCommandsToProcess)
.Select(i => commandProcessor.ProcessCommand(new IncrementRoot("bimse!")))
.Last();
viewManager.WaitUntilProcessed(lastResult, TimeSpan.FromMinutes(2)).Wait();
Console.WriteLine();
Console.WriteLine("Processing {0} commands took {1:0.0} s in total", numberOfCommandsToProcess, stopwatch.Elapsed.TotalSeconds);
Console.WriteLine();
var maxTime = handleTimes.Max(t => t.Elapsed);
var statsLines = string.Join(Environment.NewLine, handleTimes
.GroupBy(l => RoundToSeconds(l, TimeSpan.FromSeconds(10)))
.Select(g => new DispatchStats(g.Key, TimeSpan.FromSeconds(g.Average(e => e.Elapsed.TotalSeconds))))
.Select(time =>
{
var timeString = time.Elapsed.TotalSeconds.ToString("0.00").PadLeft(8);
var bar = new string('=', (int)(100.0 * (time.Elapsed.TotalSeconds / maxTime.TotalSeconds)));
return string.Concat(timeString, ": ", bar);
}));
Console.WriteLine(statsLines);
Console.WriteLine("0.00 - {0:0.00} s", maxTime.TotalSeconds);
}