Skip to content

Commit

Permalink
add jmh
Browse files Browse the repository at this point in the history
  • Loading branch information
iTitus committed Mar 23, 2022
1 parent 4ea83be commit 550ae22
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import java.time.Duration

plugins {
id 'java-library'
id 'me.champeau.jmh' version '0.6.6'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
Expand All @@ -23,6 +24,14 @@ java {
withJavadocJar()
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Test) {
systemProperty 'file.encoding', 'UTF-8'
}

javadoc {
options {
addStringOption('Xdoclint:all,-missing', '-quiet')
Expand All @@ -44,6 +53,17 @@ test {
useJUnitPlatform()
}

jmh {
jmhVersion = '1.34'
warmupIterations = 2
iterations = 5
fork = 1
}

tasks.withType(me.champeau.jmh.JmhParameters) {
jvmArgsAppend = ['-Dfile.encoding=UTF-8']
}

publishing {
publications {
MyPublication(MavenPublication) {
Expand Down
19 changes: 19 additions & 0 deletions src/jmh/java/io/github/ititus/commons/lexer/LexerBenchmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.ititus.commons.lexer;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;

@State(Scope.Benchmark)
public class LexerBenchmark {

@Benchmark
public void add(Blackhole bh) {
int a = 1;
int b = 2;
int sum = a + b;

bh.consume(sum);
}
}

0 comments on commit 550ae22

Please sign in to comment.