See the following code:
It's not doing anything exciting, just running the same inner loop 1000 times.
I have taken those times and put them in a file called 'output.txt'.
See the following python function which reads in the numbers from output.txt and plots them on a graph:
Here is the graph that it produces:
At first the code is running in the interperter, then the C1 JIT, then it settles into the C2 JIT. A couple of spikes probably indicate GC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String... args) { | |
int count = 0; | |
for (int i =0; i <1000; i++) { | |
long startTime = System.nanoTime(); | |
for (int j = 0; j < 1000; j ++) { | |
count += j; | |
} | |
long endtime = System.nanoTime(); | |
System.out.printf("%d\n", endtime - startTime); | |
} | |
System.out.println(count); | |
} |
I have taken those times and put them in a file called 'output.txt'.
See the following python function which reads in the numbers from output.txt and plots them on a graph:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
ys = [] | |
with open('output.txt') as fp: | |
content = fp.readlines() | |
for line in content: | |
ys.append(int(line.strip())) | |
plt.plot(ys) | |
plt.ylabel("Time (ns)") | |
plt.show() |
At first the code is running in the interperter, then the C1 JIT, then it settles into the C2 JIT. A couple of spikes probably indicate GC.
No comments:
Post a Comment