仿真平台内核初版 -tlib库 包含<sparc arm riscv powerPC>
This commit is contained in:
42
lib/Packet.Net/Test/Rate.cs
Normal file
42
lib/Packet.Net/Test/Rate.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Compute a rate given a start and end DateTime and an event count
|
||||
/// </summary>
|
||||
public class Rate
|
||||
{
|
||||
private TimeSpan Elapsed;
|
||||
private string EventType;
|
||||
private int EventCount;
|
||||
|
||||
public Rate(DateTime Start, DateTime End,
|
||||
int EventCount, string EventType)
|
||||
{
|
||||
Elapsed = End - Start;
|
||||
this.EventCount = EventCount;
|
||||
this.EventType = EventType;
|
||||
}
|
||||
|
||||
/// <value>
|
||||
/// Returns the rate in terms of events per second
|
||||
/// </value>
|
||||
public double RatePerSecond
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((Double)EventCount / (Double)Elapsed.Ticks) * TimeSpan.TicksPerSecond;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format(" {0,10} {1} at a rate of {2,12} / second ({3} seconds elapsed)",
|
||||
EventCount,
|
||||
EventType,
|
||||
RatePerSecond.ToString("n"),
|
||||
Elapsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user