diff options
author | Jesse Wilson <jessewilson@google.com> | 2009-12-15 18:54:02 -0800 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2009-12-15 18:54:02 -0800 |
commit | 1440b36663f61ebde1952d91b4a1f4c1a27fcefa (patch) | |
tree | 35e2458d47b0de58bad416e002dc9f1e039ba9fd /src/com/google/caliper/Caliper.java | |
parent | da6e661c7e42d1358c2a49f0f02c7adc8e0a1671 (diff) | |
download | caliper-1440b36663f61ebde1952d91b4a1f4c1a27fcefa.tar.gz |
Updating caliper to current SVN as of 20091215
A test
A test/com
A test/com/google
A test/com/google/caliper
A test/com/google/caliper/AllTests.java
A test/com/google/caliper/examples
A test/com/google/caliper/examples/ArraySortBenchmark.java
A test/com/google/caliper/examples/BoxedDoubleToStringBenchmark.java
A test/com/google/caliper/examples/ListIterationBenchmark.java
A test/com/google/caliper/examples/IntModBenchmark.java
A test/com/google/caliper/examples/CharacterBenchmark.java
A test/com/google/caliper/examples/PrimitiveDoubleToStringBenchmark.java
A test/com/google/caliper/examples/StringBuilderBenchmark.java
A test/com/google/caliper/examples/EnumSetContainsBenchmark.java
A test/com/google/caliper/examples/ExpensiveObjectsBenchmark.java
A test/com/google/caliper/examples/FormatterBenchmark.java
A lib
A lib/junit.jar
A lib/google-collect-1.0-rc4.jar
A src
A src/com
A src/com/google
A src/com/google/caliper
A src/com/google/caliper/Caliper.java
A src/com/google/caliper/Param.java
A src/com/google/caliper/Parameter.java
A src/com/google/caliper/ExecutionException.java
A src/com/google/caliper/Run.java
A src/com/google/caliper/SimpleBenchmark.java
A src/com/google/caliper/ConfigurationException.java
A src/com/google/caliper/Runner.java
A src/com/google/caliper/TypeConverter.java
A src/com/google/caliper/TimedRunnable.java
A src/com/google/caliper/Benchmark.java
A src/com/google/caliper/ConsoleReport.java
A src/com/google/caliper/Result.java
A caliper.ipr
A core.iml
A COPYING
A build.xml
Checked out revision 23.
Diffstat (limited to 'src/com/google/caliper/Caliper.java')
-rw-r--r-- | src/com/google/caliper/Caliper.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/com/google/caliper/Caliper.java b/src/com/google/caliper/Caliper.java index 855101e..315431f 100644 --- a/src/com/google/caliper/Caliper.java +++ b/src/com/google/caliper/Caliper.java @@ -34,13 +34,13 @@ class Caliper { this.runNanos = runMillis * 1000000; } - public double warmUp(Benchmark benchmark) throws Exception { + public double warmUp(TimedRunnable timedRunnable) throws Exception { long startNanos = System.nanoTime(); long endNanos = startNanos + warmupNanos; int trials = 0; long currentNanos; while ((currentNanos = System.nanoTime()) < endNanos) { - benchmark.run(1); + timedRunnable.run(1); trials++; } double nanosPerExecution = (currentNanos - startNanos) / trials; @@ -54,8 +54,11 @@ class Caliper { * In the run proper, we predict how extrapolate based on warmup how many * runs we're going to need, and run them all in a single batch. */ - public double run(Benchmark test, double estimatedNanosPerTrial) throws Exception { + public double run(TimedRunnable test, double estimatedNanosPerTrial) throws Exception { int trials = (int) (runNanos / estimatedNanosPerTrial); + if (trials == 0) { + trials = 1; + } long startNanos = System.nanoTime(); test.run(trials); long endNanos = System.nanoTime(); |