• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Okio Benchmarks
2------------
3
4This module contains microbenchmarks that can be used to measure various aspects of performance for Okio buffers. Okio benchmarks are written using JMH (version 1.4.1 at this time) and require Java 7.
5
6Running Locally
7-------------
8
9To run benchmarks locally, first build and package the project modules:
10
11```
12$ mvn clean package
13```
14
15This should create a `benchmarks.jar` file in the `target` directory, which is a typical JMH benchmark JAR:
16
17```
18$ java -jar benchmarks/target/benchmarks.jar -l
19Benchmarks:
20com.squareup.okio.benchmarks.BufferPerformanceBench.cold
21com.squareup.okio.benchmarks.BufferPerformanceBench.threads16hot
22com.squareup.okio.benchmarks.BufferPerformanceBench.threads1hot
23com.squareup.okio.benchmarks.BufferPerformanceBench.threads2hot
24com.squareup.okio.benchmarks.BufferPerformanceBench.threads32hot
25com.squareup.okio.benchmarks.BufferPerformanceBench.threads4hot
26com.squareup.okio.benchmarks.BufferPerformanceBench.threads8hot
27```
28
29More help is available using the `-h` option. A typical run on Mac OS X looks like:
30
31```
32$ /usr/libexec/java_home -v 1.7 --exec java -jar benchmarks/target/benchmarks.jar \
33"cold" -prof gc,hs_rt,stack -r 60 -t 4 \
34-jvmArgsPrepend "-Xms1G -Xmx1G -XX:+HeapDumpOnOutOfMemoryError"
35```
36
37This executes the "cold" buffer usage benchmark, using the default number of measurement and warm-up iterations, forks, and threads; it adjusts the thread count to 4, iteration time to 60 seconds, fixes the heap size at 1GB and profiles the benchmark using JMH's GC, Hotspot runtime and stack sampling profilers.
38
39