Skip to content

Instantly share code, notes, and snippets.

@buchgr
Created September 19, 2016 07:19
Show Gist options
  • Save buchgr/9e5504b314ff302841f4b536de8e629b to your computer and use it in GitHub Desktop.
Save buchgr/9e5504b314ff302841f4b536de8e629b to your computer and use it in GitHub Desktop.
Simple EA test
package io.grpc;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by buchgr on 9/19/16.
*/
@State(Scope.Thread)
public class FooBenchmark {
private final List<String> list = new ArrayList<String>(1024);
@Benchmark
public Iterator<String> baseline() {
return list.iterator();
}
@Benchmark
public void no_alloc() {
no_alloc0();
}
@Benchmark
public void no_alloc_but_alloc() {
no_alloc1();
}
Iterator<String> no_alloc0() {
return list.iterator();
}
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
Iterator<String> no_alloc1() {
return list.iterator();
}
}
/**
FooBenchmark.baseline thrpt 10 183072649.740 ± 4957161.238 ops/s
FooBenchmark.baseline:·gc.alloc.rate thrpt 10 5585.307 ± 152.000 MB/sec
FooBenchmark.baseline:·gc.alloc.rate.norm thrpt 10 32.000 ± 0.001 B/op
FooBenchmark.baseline:·gc.churn.PS_Eden_Space thrpt 10 5635.544 ± 497.420 MB/sec
FooBenchmark.baseline:·gc.churn.PS_Eden_Space.norm thrpt 10 32.276 ± 2.286 B/op
FooBenchmark.baseline:·gc.churn.PS_Survivor_Space thrpt 10 0.118 ± 0.066 MB/sec
FooBenchmark.baseline:·gc.churn.PS_Survivor_Space.norm thrpt 10 0.001 ± 0.001 B/op
FooBenchmark.baseline:·gc.count thrpt 10 83.000 counts
FooBenchmark.baseline:·gc.time thrpt 10 34.000 ms
FooBenchmark.no_alloc thrpt 10 1478470149.525 ± 42938626.179 ops/s
FooBenchmark.no_alloc:·gc.alloc.rate thrpt 10 0.002 ± 0.005 MB/sec
FooBenchmark.no_alloc:·gc.alloc.rate.norm thrpt 10 ≈ 10⁻⁶ B/op
FooBenchmark.no_alloc:·gc.count thrpt 10 ≈ 0 counts
FooBenchmark.no_alloc_but_alloc thrpt 10 155216657.107 ± 7920942.906 ops/s
FooBenchmark.no_alloc_but_alloc:·gc.alloc.rate thrpt 10 4735.646 ± 241.374 MB/sec
FooBenchmark.no_alloc_but_alloc:·gc.alloc.rate.norm thrpt 10 32.000 ± 0.001 B/op
FooBenchmark.no_alloc_but_alloc:·gc.churn.PS_Eden_Space thrpt 10 4755.211 ± 487.553 MB/sec
FooBenchmark.no_alloc_but_alloc:·gc.churn.PS_Eden_Space.norm thrpt 10 32.129 ± 2.789 B/op
FooBenchmark.no_alloc_but_alloc:·gc.churn.PS_Survivor_Space thrpt 10 0.078 ± 0.040 MB/sec
FooBenchmark.no_alloc_but_alloc:·gc.churn.PS_Survivor_Space.norm thrpt 10 0.001 ± 0.001 B/op
FooBenchmark.no_alloc_but_alloc:·gc.count thrpt 10 70.000 counts
FooBenchmark.no_alloc_but_alloc:·gc.time thrpt 10 29.000 ms
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment