Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit aa8f147

Browse files
author
Kris Williams
committed
Fixes for test time assertions, switching to hi-rez timer
1 parent 1add166 commit aa8f147

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Test/UUIDGeneratorTest.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,19 @@ public void testGenerateTimeBasedUUID()
305305
// before we generate all the uuids, lets get the start time
306306
long start_time = Environment.TickCount;
307307

308+
// high-resolution timer
309+
Stopwatch timer = Stopwatch.StartNew();
310+
308311
// now create the array of uuids
309312
for (int i = 0; i < uuid_array.Length; i++)
310313
{
311314
uuid_array[i] = uuid_gen.GenerateTimeBasedUUID();
312315
}
313316

317+
timer.Stop();
318+
314319
// now capture the end time
315-
long end_time = Environment.TickCount;
320+
long end_time = start_time + timer.ElapsedTicks;
316321

317322
// check that none of the UUIDs are null
318323
checkUUIDArrayForNonNullUUIDs(uuid_array);
@@ -372,8 +377,8 @@ public void testGenerateTimeBasedUUIDWithEthernetAddress()
372377
// before we generate all the uuids, lets get the start time
373378
long start_time = Environment.TickCount;
374379

375-
// high-resolution timer
376-
var timer = Stopwatch.StartNew();
380+
// high-resolution timer
381+
Stopwatch timer = Stopwatch.StartNew();
377382

378383
// now create the array of uuids
379384
for (int i = 0; i < uuid_array.Length; i++)

Test/UUIDTimerTest.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Collections.Generic;
2121
using System.Net.NetworkInformation;
2222
using System.Security.Cryptography;
23+
using System.Diagnostics;
2324

2425
namespace Jug.Test
2526
{
@@ -145,15 +146,19 @@ public void testGetTimestamp()
145146
// before generating all the uuid timer arrays, get the start time
146147
long start_time = Environment.TickCount;
147148

149+
Stopwatch timer = Stopwatch.StartNew();
150+
148151
// now create the array of uuid timer output arrays
149152
for (int i = 0; i < array_of_uuid_timer_byte_arrays.Length; i++)
150153
{
151154
array_of_uuid_timer_byte_arrays[i] = new byte[UUID_TIMER_ARRAY_LENGTH];
152155
uuid_timer.GetTimestamp(array_of_uuid_timer_byte_arrays[i]);
153156
}
154157

158+
timer.Stop();
159+
155160
// now capture the end time
156-
long end_time = Environment.TickCount;
161+
long end_time = start_time + timer.ElapsedTicks;
157162

158163
// convert the array into array of longs holding the numerical values
159164
long[] uuid_timer_array_of_longs =

0 commit comments

Comments
 (0)