File tree 1 file changed +43
-0
lines changed
benchmark-runners/src/main/java/com/luxoft/logeek/benchmark/sequence
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .luxoft .logeek .benchmark .sequence ;
2
+
3
+ import com .luxoft .logeek .benchmark .ContextAwareBenchmark ;
4
+ import org .openjdk .jmh .annotations .*;
5
+
6
+ import javax .persistence .EntityManager ;
7
+ import java .util .concurrent .TimeUnit ;
8
+
9
+ @ State (Scope .Thread )
10
+ @ BenchmarkMode (Mode .AverageTime )
11
+ @ OutputTimeUnit (TimeUnit .NANOSECONDS )
12
+ public class QueryValidationBenchmark extends ContextAwareBenchmark {
13
+
14
+ private EntityManager entityManager ;
15
+
16
+ @ Setup
17
+ public void init () {
18
+ super .init ();
19
+ entityManager = context .getBean (EntityManager .class );
20
+ }
21
+
22
+ @ Benchmark
23
+ public Object measureQuery () {
24
+ return validateQueryDefault ();
25
+ }
26
+
27
+ private Object validateQueryDefault () {
28
+ EntityManager validatingEm = null ;
29
+
30
+ try {
31
+ validatingEm = entityManager .getEntityManagerFactory ().createEntityManager ();
32
+ return validatingEm .createQuery ("select r from CpyEntity r " );
33
+
34
+ } catch (RuntimeException e ) {
35
+ throw new IllegalArgumentException ("" , e );
36
+ } finally {
37
+ if (validatingEm != null ) {
38
+ validatingEm .close ();
39
+ }
40
+ }
41
+ }
42
+
43
+ }
You can’t perform that action at this time.
0 commit comments