1
1
/*
2
- * Copyright (c) 2012, 2016 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2012, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -177,7 +177,8 @@ public void test_ClockResolution() {
177
177
+ formatTime ("\n \t highest1" , highest1 ));
178
178
}
179
179
180
- int count =0 ;
180
+ int countBetterThanMillisPrecision = 0 ;
181
+ int countBetterThanMicrosPrecision = 0 ;
181
182
// let's preheat the system a bit:
182
183
int lastNanos = 0 ;
183
184
for (int i = 0 ; i < 1000 ; i ++) {
@@ -191,7 +192,10 @@ public void test_ClockResolution() {
191
192
lastNanos = nanos ;
192
193
193
194
if ((nanos % 1000000 ) > 0 ) {
194
- count ++; // we have micro seconds
195
+ countBetterThanMillisPrecision ++; // we have microseconds
196
+ }
197
+ if ((nanos % 1000 ) > 0 ) {
198
+ countBetterThanMicrosPrecision ++; // we have nanoseconds
195
199
}
196
200
if ((sysnan % 1000000 ) > 0 ) {
197
201
throw new RuntimeException ("Expected only millisecconds "
@@ -200,13 +204,17 @@ public void test_ClockResolution() {
200
204
}
201
205
}
202
206
System .out .println ("\n Number of time stamps which had better than"
203
- + " millisecond precision: " +count +"/" +1000 );
207
+ + " millisecond precision: "
208
+ + countBetterThanMillisPrecision + "/" + 1000 );
209
+ System .out .println ("\n Number of time stamps which had better than"
210
+ + " microsecond precision: "
211
+ + countBetterThanMicrosPrecision + "/" + 1000 );
204
212
System .out .println (formatTime ("\n systemUTC " , system1 ));
205
213
System .out .println (formatTime ("highestResolutionUTC " , highest1 ));
206
- if (count == 0 ) {
214
+ if (countBetterThanMillisPrecision == 0 ) {
207
215
System .err .println ("Something is strange: no microsecond "
208
- + "precision with highestResolutionUTC?" );
209
- throw new RuntimeException ("Micro second preccision not reached" );
216
+ + "precision with highestResolutionUTC?" );
217
+ throw new RuntimeException ("Micro second precision not reached" );
210
218
}
211
219
212
220
// check again
0 commit comments