@Threads(1) @Benchmark public void baseline(Blackhole bh) { PrependId id = new PrependId("http.req.complete", null) .withTag( "nf.app", "test_app") .withTag("nf.cluster", "test_app-main") .withTag( "nf.asg", "test_app-main-v042") .withTag( "nf.stack", "main") .withTag( "nf.ami", "ami-0987654321") .withTag( "nf.region", "us-east-1") .withTag( "nf.zone", "us-east-1e") .withTag( "nf.node", "i-1234567890") .withTag( "country", "US") .withTag( "device", "xbox") .withTag( "status", "200") .withTag( "client", "ab"); bh.consume(id); }
@Threads(1) @Benchmark public void withTag(Blackhole bh) { Id id = registry.createId("http.req.complete") .withTag( "nf.app", "test_app") .withTag("nf.cluster", "test_app-main") .withTag( "nf.asg", "test_app-main-v042") .withTag( "nf.stack", "main") .withTag( "nf.ami", "ami-0987654321") .withTag( "nf.region", "us-east-1") .withTag( "nf.zone", "us-east-1e") .withTag( "nf.node", "i-1234567890") .withTag( "country", "US") .withTag( "device", "xbox") .withTag( "status", "200") .withTag( "client", "ab"); bh.consume(id); }
@Threads(1) @Benchmark public void withTagsVararg(Blackhole bh) { Id id = registry.createId("http.req.complete").withTags( "nf.app", "test_app", "nf.cluster", "test_app-main", "nf.asg", "test_app-main-v042", "nf.stack", "main", "nf.ami", "ami-0987654321", "nf.region", "us-east-1", "nf.zone", "us-east-1e", "nf.node", "i-1234567890", "country", "US", "device", "xbox", "status", "200", "client", "ab"); bh.consume(id); }
@Threads(1) @Benchmark public void withTagsVarargSorted(Blackhole bh) { Id id = registry.createId("http.req.complete").withTags( "client", "ab", "country", "US", "device", "xbox", "nf.ami", "ami-0987654321", "nf.app", "test_app", "nf.asg", "test_app-main-v042", "nf.cluster", "test_app-main", "nf.node", "i-1234567890", "nf.region", "us-east-1", "nf.stack", "main", "nf.zone", "us-east-1e", "status", "200" ); bh.consume(id); }
private void generateImport(PrintWriter writer) { Class<?>[] imports = new Class<?>[]{ List.class, AtomicInteger.class, Collection.class, ArrayList.class, TimeUnit.class, Generated.class, CompilerControl.class, InfraControl.class, ThreadParams.class, Result.class, ThroughputResult.class, AverageTimeResult.class, SampleTimeResult.class, SingleShotResult.class, SampleBuffer.class, Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class, BenchmarkMode.class, RawResults.class, ResultRole.class, Field.class, BenchmarkParams.class, IterationParams.class }; for (Class<?> c : imports) { writer.println("import " + c.getName() + ';'); } writer.println(); }
@Benchmark @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Fork(value = 1) @Threads(1) @Warmup(iterations = 5) @Measurement(iterations = 20) public void testCascadedValidation(ParsingBeansSpeedState state, Blackhole bh) { // Validator in new factory for ( Object o : state.holder.beans ) { bh.consume( state.validator.getConstraintsForClass( o.getClass() ).isBeanConstrained() ); } }
@Benchmark @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @Fork(value = 1) @Threads(50) @Warmup(iterations = 20) // it seems that as there are a lot of beans it takes some time to warmup @Measurement(iterations = 30) public void testCascadedValidation(RawValidationSpeedState state, Blackhole bh) { for ( Object o : state.holder.beans ) { Set<ConstraintViolation<Object>> constraintViolations = state.validator.validate( o ); bh.consume( constraintViolations ); } }
@Benchmark @Threads(Threads.MAX) public void measureNaiveObjectCreation() throws Exception { Thing thing = new Thing(1); things.add(thing); things.remove(thing); }
@Benchmark @Threads(Threads.MAX) public void measureAcquireAndReleaseMultithreaded() throws Exception { try (Resource<Thing> thingResource = pool.get()) { Thing thing = thingResource.get(); assertNotNull(thing); assertTrue(thing.getId() >= 1); } }
@Benchmark @Fork(value = FORK_COUNT) @Threads(value = THREAD_COUNT) @Warmup(iterations = WARMUP_COUNT) @Measurement(iterations = ITERATION_COUNT) public String directSupplier() { return stringSupplier.get(); }
@Benchmark @Fork(value = FORK_COUNT) @Threads(value = THREAD_COUNT) @Warmup(iterations = WARMUP_COUNT) @Measurement(iterations = ITERATION_COUNT) public String protectedSupplier() { return protectedSupplier.get(); }
@Benchmark @Fork(value = FORK_COUNT) @Threads(value = THREAD_COUNT) @Warmup(iterations = WARMUP_COUNT) @Measurement(iterations = ITERATION_COUNT) public String protectedSupplierWithSubscriber() { return protectedSupplierWithSb.get(); }
@Benchmark @Threads(value = THREAD_COUNT) @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) public String semaphoreBasedPermission() { return semaphoreGuardedSupplier.get(); }
@Benchmark @Threads(value = THREAD_COUNT) @Warmup(iterations = WARMUP_COUNT) @Fork(value = FORK_COUNT) @Measurement(iterations = ITERATION_COUNT) public String atomicPermission() { return atomicGuardedSupplier.get(); }
/** * @param state Benchmark context. * @throws Exception If failed. */ @Benchmark @Threads(4) public void completeFutureGet(CompleteState state) throws Exception { GridFutureAdapter<Long> fut = new GridFutureAdapter<>(); state.queue.put(fut); fut.get(); }
@Threads(1) @Benchmark public void append2(Blackhole bh) { Id id = baseId.withTags( "country", "US", "device", "xbox"); bh.consume(id); }
@Threads(1) @Benchmark public void append4(Blackhole bh) { Id id = baseId.withTags( "country", "US", "device", "xbox", "status", "200", "client", "ab"); bh.consume(id); }
@Threads(1) @Benchmark public void append4sorted(Blackhole bh) { Id id = baseId.withTags( "client", "ab", "country", "US", "device", "xbox", "status", "200"); bh.consume(id); }
@Threads(1) @Benchmark public void emptyAppend2(Blackhole bh) { Id id = emptyId.withTags( "country", "US", "device", "xbox"); bh.consume(id); }
@Threads(1) @Benchmark public void emptyAppend4sorted(Blackhole bh) { Id id = emptyId.withTags( "client", "ab", "country", "US", "device", "xbox", "status", "200"); bh.consume(id); }
@Threads(1) @Benchmark public void arrayForLoop(Blackhole bh) { int v = 0; int n = arr.length; for (int i = 0; i < n; ++i) { v += arr[i]; } bh.consume(v); }
@Threads(1) @Benchmark public void arrayForeach(Blackhole bh) { int v = 0; for (char c : arr) { v += c; } bh.consume(v); }
@Threads(1) @Benchmark public void strForLoop(Blackhole bh) { int v = 0; int n = str.length(); for (int i = 0; i < n; ++i) { v += str.charAt(i); } bh.consume(v); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { testInvocationThread.add(Thread.currentThread()); Fixtures.work(); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test() { tickRun = TICKER.incrementAndGet(); Fixtures.work(); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test(MyState state) { state.tickRun = TICKER.incrementAndGet(); Fixtures.work(); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void doTest() { Assert.fail(); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); }
@Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); }
@Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); }