31 lines
922 B
C#
31 lines
922 B
C#
using System;
|
|
namespace ln.perfdb
|
|
{
|
|
public class TimeWindow
|
|
{
|
|
public int NumRecords { get; private set; }
|
|
public int Interval { get; private set; }
|
|
|
|
public TimeWindow(int numRecords, int interval)
|
|
{
|
|
NumRecords = numRecords;
|
|
Interval = interval;
|
|
}
|
|
public TimeWindow(TimeSpan timeSpan, int interval)
|
|
{
|
|
Interval = interval;
|
|
TimeSpan = timeSpan;
|
|
}
|
|
|
|
public TimeSpan TimeSpan {
|
|
get => TimeSpan.FromSeconds(NumRecords * Interval);
|
|
private set => NumRecords = (int)(value.TotalSeconds / Interval);
|
|
}
|
|
|
|
public int GetValuePositionFromTimestamp(long timestamp) => ((int)(timestamp / Interval));
|
|
public int GetValueIndexFromTimestamp(long timestamp) => ((int)(timestamp / Interval)) % NumRecords;
|
|
|
|
public long ByteSize => NumRecords * 16;
|
|
}
|
|
}
|