Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stsypanov committed Jul 6, 2018
1 parent 6f76536 commit 5b30d36
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.luxoft.logeek.benchmark.sequence;

import com.luxoft.logeek.benchmark.ContextAwareBenchmark;
import org.openjdk.jmh.annotations.*;

import javax.persistence.EntityManager;
import java.util.concurrent.TimeUnit;

@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class QueryValidationBenchmark extends ContextAwareBenchmark {

private EntityManager entityManager;

@Setup
public void init() {
super.init();
entityManager = context.getBean(EntityManager.class);
}

@Benchmark
public Object measureQuery() {
return validateQueryDefault();
}

private Object validateQueryDefault() {
EntityManager validatingEm = null;

try {
validatingEm = entityManager.getEntityManagerFactory().createEntityManager();
return validatingEm.createQuery("select r from CpyEntity r ");

} catch (RuntimeException e) {
throw new IllegalArgumentException("", e);
} finally {
if (validatingEm != null) {
validatingEm.close();
}
}
}

}

0 comments on commit 5b30d36

Please sign in to comment.