ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Collection/IteratorMicroBenchmark.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Collection/IteratorMicroBenchmark.java (file contents):
Revision 1.37 by jsr166, Sun Mar 25 19:00:09 2018 UTC vs.
Revision 1.38 by jsr166, Mon Mar 26 20:33:27 2018 UTC

# Line 77 | Line 77 | public class IteratorMicroBenchmark {
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;
# Line 126 | Line 133 | public class IteratorMicroBenchmark {
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++) {
# Line 135 | Line 142 | public class IteratorMicroBenchmark {
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          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines