File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6969 <Compile Include =" Recording\RecorderTestWithLongHistogram.cs" />
7070 <Compile Include =" Recording\RecorderTestWithLShortHistogram.cs" />
7171 <Compile Include =" ShortHistogramTests.cs" />
72+ <Compile Include =" TimeStampTests.cs" />
7273 </ItemGroup >
7374 <ItemGroup >
7475 <Service Include =" {82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Diagnostics ;
3+ using System . Threading ;
4+ using NUnit . Framework ;
5+
6+ namespace HdrHistogram . UnitTests
7+ {
8+ [ TestFixture ]
9+ public class TimeStampTests
10+ {
11+ [ Test ]
12+ public void TimeStamp_values_are_accurate ( )
13+ {
14+ var delay = TimeSpan . FromSeconds ( 1 ) ;
15+ var expected = TimeStamp . Seconds ( delay . Seconds ) ;
16+
17+ var start = Stopwatch . GetTimestamp ( ) ;
18+ Thread . Sleep ( delay ) ;
19+ var end = Stopwatch . GetTimestamp ( ) ;
20+ var actual = end - start ;
21+
22+ Assert . AreEqual ( expected , actual , expected * 0.05 ) ;
23+ Assert . AreEqual ( TimeStamp . Seconds ( 60 ) , TimeStamp . Minutes ( 1 ) ) ;
24+ Assert . AreEqual ( TimeStamp . Minutes ( 60 ) , TimeStamp . Hours ( 1 ) ) ;
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 8383 <Compile Include =" Properties\AssemblyInfo.g.cs" />
8484 <Compile Include =" Recorder.cs" />
8585 <Compile Include =" ShortHistogram.cs" />
86+ <Compile Include =" TimeStamp.cs" />
8687 <Compile Include =" Utilities\ArrayExtensions.cs" />
8788 <Compile Include =" Utilities\Bitwise.cs" />
8889 <Compile Include =" LongHistogram.cs" />
Original file line number Diff line number Diff line change @@ -35,21 +35,4 @@ public static class OutputScalingFactor
3535 /// </summary>
3636 public static readonly double TimeStampToSeconds = Stopwatch . Frequency ;
3737 }
38-
39- public static class TimeStamp
40- {
41- public static long Seconds ( int seconds )
42- {
43- return Stopwatch . Frequency * seconds ;
44- }
45-
46- public static long Minutes ( int minutes )
47- {
48- return Stopwatch . Frequency * minutes * 60L ;
49- }
50- public static long Hours ( int hours )
51- {
52- return Stopwatch . Frequency * hours * 60L * 60L ;
53- }
54- }
5538}
Original file line number Diff line number Diff line change 1+ using System . Diagnostics ;
2+
3+ namespace HdrHistogram
4+ {
5+ /// <summary>
6+ /// Helper methods to get time periods based in system stopwatch units.
7+ /// </summary>
8+ public static class TimeStamp
9+ {
10+ /// <summary>
11+ /// Return a <see cref="long"/> representing the number system timer ticks that occur over the provided number of seconds.
12+ /// </summary>
13+ /// <param name="seconds">A number seconds to represent.</param>
14+ /// <returns>The number of system timer ticks that represent the <paramref name="seconds"/>.</returns>
15+ public static long Seconds ( int seconds )
16+ {
17+ return Stopwatch . Frequency * seconds ;
18+ }
19+
20+ /// <summary>
21+ /// Return a <see cref="long"/> representing the number system timer ticks that occur over the provided number of minutes.
22+ /// </summary>
23+ /// <param name="minutes">A number minutes to represent.</param>
24+ /// <returns>The number of system timer ticks that represent the <paramref name="minutes"/>.</returns>
25+ public static long Minutes ( int minutes )
26+ {
27+ return Stopwatch . Frequency * minutes * 60L ;
28+ }
29+
30+ /// <summary>
31+ /// Return a <see cref="long"/> representing the number system timer ticks that occur over the provided number of hours.
32+ /// </summary>
33+ /// <param name="hours">A number hours to represent.</param>
34+ /// <returns>The number of system timer ticks that represent the <paramref name="hours"/>.</returns>
35+ public static long Hours ( int hours )
36+ {
37+ return Stopwatch . Frequency * hours * 60L * 60L ;
38+ }
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments