xref: /aosp_15_r20/external/okhttp/okio/benchmarks/README.md (revision ab625e417e7950f52094c019474d2a9e9f14a68c)
1*ab625e41SAndroid Build Coastguard WorkerOkio Benchmarks
2*ab625e41SAndroid Build Coastguard Worker------------
3*ab625e41SAndroid Build Coastguard Worker
4*ab625e41SAndroid Build Coastguard WorkerThis 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*ab625e41SAndroid Build Coastguard Worker
6*ab625e41SAndroid Build Coastguard WorkerRunning Locally
7*ab625e41SAndroid Build Coastguard Worker-------------
8*ab625e41SAndroid Build Coastguard Worker
9*ab625e41SAndroid Build Coastguard WorkerTo run benchmarks locally, first build and package the project modules:
10*ab625e41SAndroid Build Coastguard Worker
11*ab625e41SAndroid Build Coastguard Worker```
12*ab625e41SAndroid Build Coastguard Worker$ mvn clean package
13*ab625e41SAndroid Build Coastguard Worker```
14*ab625e41SAndroid Build Coastguard Worker
15*ab625e41SAndroid Build Coastguard WorkerThis should create a `benchmarks.jar` file in the `target` directory, which is a typical JMH benchmark JAR:
16*ab625e41SAndroid Build Coastguard Worker
17*ab625e41SAndroid Build Coastguard Worker```
18*ab625e41SAndroid Build Coastguard Worker$ java -jar benchmarks/target/benchmarks.jar -l
19*ab625e41SAndroid Build Coastguard WorkerBenchmarks:
20*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.cold
21*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads16hot
22*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads1hot
23*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads2hot
24*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads32hot
25*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads4hot
26*ab625e41SAndroid Build Coastguard Workercom.squareup.okio.benchmarks.BufferPerformanceBench.threads8hot
27*ab625e41SAndroid Build Coastguard Worker```
28*ab625e41SAndroid Build Coastguard Worker
29*ab625e41SAndroid Build Coastguard WorkerMore help is available using the `-h` option. A typical run on Mac OS X looks like:
30*ab625e41SAndroid Build Coastguard Worker
31*ab625e41SAndroid Build Coastguard Worker```
32*ab625e41SAndroid Build Coastguard Worker$ /usr/libexec/java_home -v 1.7 --exec java -jar benchmarks/target/benchmarks.jar \
33*ab625e41SAndroid Build Coastguard Worker"cold" -prof gc,hs_rt,stack -r 60 -t 4 \
34*ab625e41SAndroid Build Coastguard Worker-jvmArgsPrepend "-Xms1G -Xmx1G -XX:+HeapDumpOnOutOfMemoryError"
35*ab625e41SAndroid Build Coastguard Worker```
36*ab625e41SAndroid Build Coastguard Worker
37*ab625e41SAndroid Build Coastguard WorkerThis 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*ab625e41SAndroid Build Coastguard Worker
39