public final class BenchmarkSuite extends Object
Results can be optionally sanitized - any result that is outside of mean +/- margin * delta is removed from the result set. This helps remove random outliers.
StringBuilder sb = new StringBuilder(); Formatter fmt = new Formatter(sb); BenchmarkSuite suite = new BenchmarkSuite(); // Arrange various benchmarks in a suite BenchmarkSuite result = suite .setScale(scale) .doSanitize(true) .add("someBenchmark", someBenchmarkFunc) .add("anotherBenchmark", anotherBenchmarkFunc) .runMatching(patterns, exclude); result.display(fmt);
Constructor and Description |
---|
BenchmarkSuite() |
Modifier and Type | Method and Description |
---|---|
BenchmarkSuite |
add(@NotNull String name,
@NotNull Supplier<org.apache.commons.math3.stat.descriptive.DescriptiveStatistics> b)
Add new benchmark to the suite.
|
BenchmarkSuite |
doSanitize(boolean sanitize)
Enable or disable result sanitization.
|
Map<String,org.apache.commons.math3.stat.descriptive.DescriptiveStatistics> |
getResult()
Get raw benchmark results
|
List<String> |
listMatching(@Nullable Pattern[] positive,
@Nullable Pattern[] negatve)
Return list of benchmark names that match positive patterns and do not
match negative patterns.
|
BenchmarkSuite |
runMatching(@Nullable Pattern[] positive,
@Nullable Pattern[] negatve)
Run all benchmarks (filtered by positive and negative matches.
|
BenchmarkSuite |
setScale(TimeUnit scale)
Set scaling factor for displaying results.
|
public BenchmarkSuite setScale(TimeUnit scale)
scale:
- scaling factorpublic BenchmarkSuite doSanitize(boolean sanitize)
sanitize
- enable sanitization if true, disable if falsepublic Map<String,org.apache.commons.math3.stat.descriptive.DescriptiveStatistics> getResult()
public List<String> listMatching(@Nullable @Nullable Pattern[] positive, @Nullable @Nullable Pattern[] negatve)
positive
- regexp patterns that should match benchmark namenegatve
- regexp patterns that should be excluded when matchespublic BenchmarkSuite runMatching(@Nullable @Nullable Pattern[] positive, @Nullable @Nullable Pattern[] negatve)
listMatching(Pattern[], Pattern[])
for details.positive
- regexp patterns that should match benchmark namenegatve
- regexp patterns that should be excluded when matchespublic BenchmarkSuite add(@NotNull @NotNull String name, @NotNull @NotNull Supplier<org.apache.commons.math3.stat.descriptive.DescriptiveStatistics> b)
name
- benchmark nameb
- benchmark corresponding to nameCopyright © 2018. All rights reserved.