本文整理汇总了C#中Stat.Max方法的典型用法代码示例。如果您正苦于以下问题:C# Stat.Max方法的具体用法?C# Stat.Max怎么用?C# Stat.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stat
的用法示例。
在下文中一共展示了Stat.Max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public bool Execute(CommandProcessorContext context, CancellationToken token, string[] args)
{
var batchCount = 15;
var batchSize = 10000;
var projectionCount = 10;
var readerCount = 10;
if (args.Length > 0)
int.TryParse(args[0], out batchCount);
if (args.Length > 1)
int.TryParse(args[1], out batchSize);
if (args.Length > 2)
int.TryParse(args[2], out projectionCount);
if (args.Length > 3)
int.TryParse(args[3], out readerCount);
context.Log.Debug("batchCount: {0}", batchCount);
context.Log.Debug("batchSize: {0}", batchSize);
context.Log.Debug("projectionCount: {0}", projectionCount);
context.Log.Debug("readerCount: {0}", readerCount);
var startEvt = new ManualResetEventSlim(false);
_failures = 0;
var streamId = "SmartAppTest-" + Guid.NewGuid();
var totalSw = Stopwatch.StartNew();
// write half of data to the stream
var writeStat = new Stat();
WriteEvents(streamId, batchCount / 2, batchSize, context, writeStat);
var wrBytesPerSec = writeStat.ElapsedMsec > 0 ? (writeStat.Count * 1000D / writeStat.ElapsedMsec) : 0;
context.Log.Debug("Events write throughput: {0}", FormatEvil.SpeedInBytes(wrBytesPerSec));
var threads = new List<Thread>();
using (var cts = new CancellationTokenSource())
using (var linked = CancellationTokenSource.CreateLinkedTokenSource(token, cts.Token))
{
// Upload some random data to an event stream in batches (a thread and large batches)
writeStat = new Stat();
var writerThread = CreateEventWriterThread(streamId, batchCount / 2, batchSize, context, writeStat, startEvt, linked.Token);
writerThread.Start();
// run a set of projections in parallel for this event stream (1 thread per projection)
var projStat = new Stat[projectionCount];
for (var i = 0; i < projectionCount; i++)
{
projStat[i] = new Stat();
threads.Add(CreateProjectionThread(streamId, i, context, startEvt, linked.Token, projStat[i]));
threads.Last().Start();
}
// poll projected views with multiple concurrent readers
var projectionIndex = 0;
var readerStat = new Stat[readerCount];
for (var i = 0; i < readerCount; i++)
{
readerStat[i] = new Stat();
threads.Add(CreateViewReaderThread(i, projectionIndex, context, startEvt, linked.Token, readerStat[i]));
threads.Last().Start();
projectionIndex++;
if (projectionIndex >= projectionCount)
projectionIndex = 0;
}
// Start all thread
startEvt.Set();
// Wait until second half of data will be written
writerThread.Join();
// Cancel rest threads
cts.Cancel();
foreach (var thread in threads)
thread.Join();
totalSw.Stop();
// Projections stat
wrBytesPerSec = writeStat.ElapsedMsec > 0 ? (writeStat.Count * 1000D / writeStat.ElapsedMsec) : 0;
context.Log.Debug("Events write throughput under load: {0}", FormatEvil.SpeedInBytes(wrBytesPerSec));
var elapsedMsec = projStat.Max(s => s.ElapsedMsec);
var totalBytes = projStat.Sum(s => s.Count);
var bytesPerSec = elapsedMsec > 0 ? (totalBytes * 1000D / elapsedMsec) : 0;
context.Log.Debug("Events read throughput: {0}", FormatEvil.SpeedInBytes(bytesPerSec));
elapsedMsec = readerStat.Max(s => s.ElapsedMsec);
var totalReads = readerStat.Sum(s => s.Count);
var readsPerSec = elapsedMsec > 0 ? (totalReads * 1000D / elapsedMsec) : 0;
context.Log.Debug("Views object read rate: {0} instance/sec", FormatEvil.ToHumanReadable(readsPerSec));
context.Log.Info("Total time: {0}", totalSw.Elapsed);
var key = string.Format("SAB-WR-{0}-{1}-bytesPerSec", batchCount, batchSize);
PerfUtils.LogTeamCityGraphData(key, (int) wrBytesPerSec);
PerfUtils.LogTeamCityGraphData("SAB-RE-bytesPerSec", (int) bytesPerSec);
PerfUtils.LogTeamCityGraphData("SAB-RV-objectsPerSec", (int) readsPerSec);
//.........这里部分代码省略.........
示例2: PrintStat
public string PrintStat(string name, int n, double level, TimeSpan max)
{
Stat<PhaseInfo, int, int> load = new Stat<PhaseInfo, int, int>(PInfo, p => p.MaxLoad, p => p.MaxLoad);
Stat<PhaseInfo, TimeSpan, long> start = new Stat<PhaseInfo, TimeSpan, long>(PInfo, p => p.Start.TimeOfDay, p => p.Start.Ticks);
Stat<PhaseInfo, TimeSpan, long> end = new Stat<PhaseInfo, TimeSpan, long>(PInfo, p => p.End.TimeOfDay, p => p.End.Ticks);
return String.Format("{0}\t{1}\t{2}\t{3}\t{4:h\\:mm}\t{5:h\\:mm}\t{6:h\\:mm}\t{7:h\\:mm}\t{8}\t{9}\t{10}\t{11}\t{12}", name, Teams / n, load.Max(), load.Max(level), start.Min(), start.Min(level), end.Max(level), end.Max(), Time.Print(level), Div(Wait.Num, n), Wait.Print(level), Div(Rejects, n), max != TimeSpan.Zero ? max.ToString(@"h\:mm") : "");
}