(String id, long checkValue,
LongSupplier operation)
| 8 | |
| 9 | public class Summing { |
| 10 | static void timeTest(String id, long checkValue, |
| 11 | LongSupplier operation) { |
| 12 | System.out.print(id + ": "); |
| 13 | Timer timer = new Timer(); |
| 14 | long result = operation.getAsLong(); |
| 15 | if(result == checkValue) |
| 16 | System.out.println(timer.duration() + "ms"); |
| 17 | else |
| 18 | System.out.format("result: %d%ncheckValue: %d%n", |
| 19 | result, checkValue); |
| 20 | } |
| 21 | public static final int SZ = 100_000_000; |
| 22 | // This even works: |
| 23 | // public static final int SZ = 1_000_000_000; |