timestamp.patch
new/src/main/org/h2/util/CurrentTimestamp.java 2023-07-05 11:18:55 +0000 | ||
---|---|---|
6 | 6 |
package org.h2.util; |
7 | 7 | |
8 | 8 |
import org.h2.value.ValueTimestampTimeZone; |
9 |
import java.io.FileWriter; |
|
10 |
import java.io.IOException; |
|
9 | 11 | |
10 | 12 |
public final class CurrentTimestamp { |
11 | 13 | |
14 |
private static int index = 0 ; |
|
15 |
private static FileWriter file; |
|
16 |
private static long totalTime = 0 ; |
|
12 | 17 |
/* |
13 | 18 |
* Signatures of methods should match with |
14 | 19 |
* h2/src/java9/src/org/h2/util/CurrentTimestamp.java and precompiled |
... | ... | |
21 | 26 |
* @return current timestamp |
22 | 27 |
*/ |
23 | 28 |
public static ValueTimestampTimeZone get() { |
24 |
return DateTimeUtils.timestampTimeZoneFromMillis(System.currentTimeMillis()); |
|
29 |
try { |
|
30 |
file = new FileWriter("timestampGetCalls.txt", true); |
|
31 |
file.write("Index : " + ++index + "\n"); |
|
32 |
file.close(); |
|
33 |
} |
|
34 |
catch (IOException e) |
|
35 |
{ |
|
36 |
e.printStackTrace(); |
|
37 |
} |
|
38 |
long start = System.nanoTime(); |
|
39 |
ValueTimestampTimeZone returnValue = DateTimeUtils.timestampTimeZoneFromMillis(System.currentTimeMillis()); |
|
40 |
long end = System.nanoTime(); |
|
41 |
totalTime = totalTime + (end - start); |
|
42 |
try { |
|
43 |
file = new FileWriter("timestampGetCalls.txt", true); |
|
44 |
file.write("Average time : " + totalTime * 1.0 / index + "\n"); |
|
45 |
file.close(); |
|
46 |
} |
|
47 |
catch (IOException e) |
|
48 |
{ |
|
49 |
e.printStackTrace(); |
|
50 |
} |
|
51 |
return returnValue; |
|
25 | 52 |
} |
26 | 53 | |
27 | 54 |
private CurrentTimestamp() { |