77 |
|
public Job(String name) { this.name = name; } |
78 |
|
public String name() { return name; } |
79 |
|
public abstract void work() throws Throwable; |
80 |
+ |
public void run() { |
81 |
+ |
try { work(); } |
82 |
+ |
catch (Throwable ex) { |
83 |
+ |
// current job cannot always be deduced from stacktrace. |
84 |
+ |
throw new RuntimeException("Job failed: " + name(), ex); |
85 |
+ |
} |
86 |
+ |
} |
87 |
|
} |
88 |
|
|
89 |
|
final int iterations; |
133 |
|
* compiling everything worth compiling. |
134 |
|
* Returns array of average times per job per run. |
135 |
|
*/ |
136 |
< |
long[] time0(List<Job> jobs) throws Throwable { |
136 |
> |
long[] time0(List<Job> jobs) { |
137 |
|
final int size = jobs.size(); |
138 |
|
long[] nanoss = new long[size]; |
139 |
|
for (int i = 0; i < size; i++) { |
142 |
|
long totalTime; |
143 |
|
int runs = 0; |
144 |
|
long startTime = System.nanoTime(); |
145 |
< |
do { job.work(); runs++; } |
145 |
> |
do { job.run(); runs++; } |
146 |
|
while ((totalTime = System.nanoTime() - startTime) < warmupNanos); |
147 |
|
nanoss[i] = totalTime/runs; |
148 |
|
} |