Skip to content

Commit

Permalink
Benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tfij committed Oct 5, 2016
1 parent 1319d70 commit 144047d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Expand Up @@ -2,12 +2,14 @@ buildscript {
repositories { mavenCentral() }
dependencies {
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3'
classpath 'me.champeau.gradle:jmh-gradle-plugin:0.3.1'
}
}

plugins {
id 'com.bmuschko.nexus' version '2.3.1'
id 'pl.allegro.tech.build.axion-release' version '1.4.0'
id "me.champeau.gradle.jmh" version "0.3.1"
}

apply plugin: 'java'
Expand All @@ -34,6 +36,12 @@ dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'

testCompile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4'

jmh group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'
}

jmh {
jmhVersion = '1.14.1'
}

test {
Expand Down
33 changes: 33 additions & 0 deletions src/jmh/java/pl/allegro/tech/opel/OpelEngineBanchmark.java
@@ -0,0 +1,33 @@
package pl.allegro.tech.opel;

import org.openjdk.jmh.annotations.Benchmark;

public class OpelEngineBanchmark {

private static final OpelEngine engine = OpelEngineBuilder.create().build();
private static final String SIMPLE_EXPRESSION = "2 + 2 * 2";
private static final String COMPLEX_EXPRESSION = "val x = 'some string'; val y = x.length() / 10; if (x > 4) x.toLowerCase else 'lorem ipsum'";
private static final OpelParsingResult PARSED_SIMPLE_EXPRESSION = engine.parse(SIMPLE_EXPRESSION);
private static final OpelParsingResult PARSED_COMPLEX_EXPRESSION = engine.parse(COMPLEX_EXPRESSION);

@Benchmark
public void validateSimpleExpression() {
engine.eval(SIMPLE_EXPRESSION);
}

@Benchmark
public void validateComplexExpression() {
engine.eval(COMPLEX_EXPRESSION);
}

@Benchmark
public void validateSimpleParsedExpression() {
PARSED_SIMPLE_EXPRESSION.eval();
}

@Benchmark
public void validateComplexParsedExpression() {
PARSED_COMPLEX_EXPRESSION.eval();
}

}

0 comments on commit 144047d

Please sign in to comment.