Files
frameworks_base/core/tests/benchmarks
Neil Fuller 8dcdc1dd43 Add a basic benchmark for android.text.format.Time
Add a benchmark to demonstrate performance tradeoffs between
alternatives for android.text.format.Time. This can be extended later
as needed for other Time usecases.

Executable with:
vogar --mode app_process --benchmark core/tests/benchmarks/src/android/text/format/AndroidTimeVsOthersBenchmark.java

Results from an aosp/master taimen:

    Experiment selection:
      Benchmark Methods:   [toMillis_androidIucUtil, toMillis_androidTime, toMillis_javaTime, toMillis_javaUtil]
      Instruments:   [runtime]
      User parameters:   {}
      Virtual machines:  [app_process]
      Selection type:    Full cartesian product
    This selection yields 4 experiments.
    Trial Report (1 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_androidIucUtil, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=6341.29, 1st qu.=6341.29, median=6341.29, mean=6341.29, 3rd qu.=6341.29, max=6341.29
    Trial Report (2 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_androidTime, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=12310.21, 1st qu.=12310.21, median=12310.21, mean=12310.21, 3rd qu.=12310.21, max=12310.21
    Trial Report (3 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_javaTime, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=1029.36, 1st qu.=1029.36, median=1029.36, mean=1029.36, 3rd qu.=1029.36, max=1029.36
    Trial Report (4 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_javaUtil, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=10142.66, 1st qu.=10142.66, median=10142.66, mean=10142.66, 3rd qu.=10142.66, max=10142.66
    Collected 4 measurements from:
      1 instrument(s)
      1 virtual machine(s)
      4 benchmark(s)

Note: When not cycling the time zone ID the results are different, but
java.time still comes out ahead.

    Trial Report (1 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_androidIucUtil, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=6583.57, 1st qu.=6583.57, median=6583.57, mean=6583.57, 3rd qu.=6583.57, max=6583.57
    Trial Report (2 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_androidTime, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=4653.01, 1st qu.=4653.01, median=4653.01, mean=4653.01, 3rd qu.=4653.01, max=4653.01
    Trial Report (3 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_javaTime, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=1095.20, 1st qu.=1095.20, median=1095.20, mean=1095.20, 3rd qu.=1095.20, max=1095.20
    Trial Report (4 of 4):
      Experiment {instrument=runtime, benchmarkMethod=toMillis_javaUtil, vm=app_process, parameters={}}
      Results:
        runtime(ns): min=2825.56, 1st qu.=2825.56, median=2825.56, mean=2825.56, 3rd qu.=2825.56, max=2825.56

Bug: 16550209
Test: see above
Change-Id: I8f1dffb083db00c2ea4cef40fd5cc2f4acab7a89
2019-06-17 19:04:37 +01:00
..
…

These benchmarks use the Caliper benchmark framework, and can be
run on a remote device using Vogar:

http://code.google.com/p/caliper/
http://code.google.com/p/vogar/

-------------------------

Quick Command Line Reference:

# Build vogar and dependencies.
$> mmma -j32 external/vogar

# First make sure art has permissions to dalvik-cache, otherwise it will run slower with interpreter.
$> adb root

# Run vogar in benchmark mode, telling it to use app_process (not dalvikvm which is default)
# Otherwise you will likely crash with UnsatisfiedLinkError despite having correct JNI code.

$> vogar --mode app_process --benchmark path/to/Benchmark.java

# Sometimes your benchmarks might time out, if so increase the timeout:
# (--timeout goes to vogar, and --time-limit goes to caliper)
$> vogar --timeout 1000 --mode app_process --benchmark path/to/Benchmark -- --time-limit 9999s