|
5 | 5 |
|
6 | 6 | package org.postgresql.benchmark.escaping; |
7 | 7 |
|
| 8 | +import org.postgresql.benchmark.profilers.FlightRecorderProfiler; |
8 | 9 | import org.postgresql.core.Parser; |
9 | 10 |
|
10 | 11 | import org.openjdk.jmh.annotations.Benchmark; |
11 | 12 | import org.openjdk.jmh.annotations.BenchmarkMode; |
| 13 | +import org.openjdk.jmh.annotations.Fork; |
12 | 14 | import org.openjdk.jmh.annotations.Measurement; |
13 | 15 | import org.openjdk.jmh.annotations.Mode; |
14 | 16 | import org.openjdk.jmh.annotations.OutputTimeUnit; |
| 17 | +import org.openjdk.jmh.annotations.Param; |
15 | 18 | import org.openjdk.jmh.annotations.Scope; |
16 | 19 | import org.openjdk.jmh.annotations.State; |
17 | 20 | import org.openjdk.jmh.annotations.Threads; |
18 | 21 | import org.openjdk.jmh.annotations.Warmup; |
| 22 | +import org.openjdk.jmh.profile.GCProfiler; |
| 23 | +import org.openjdk.jmh.runner.Runner; |
| 24 | +import org.openjdk.jmh.runner.RunnerException; |
| 25 | +import org.openjdk.jmh.runner.options.Options; |
| 26 | +import org.openjdk.jmh.runner.options.OptionsBuilder; |
19 | 27 |
|
20 | 28 | import java.util.concurrent.TimeUnit; |
21 | 29 |
|
| 30 | +@Fork(value = 5, jvmArgsPrepend = "-Xmx128m") |
22 | 31 | @Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) |
23 | 32 | @Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) |
24 | 33 | @State(Scope.Thread) |
|
27 | 36 | @OutputTimeUnit(TimeUnit.NANOSECONDS) |
28 | 37 | public class EscapeProcessing { |
29 | 38 |
|
30 | | - private String fnEscapeSQL = "{fn week({d '2005-01-24'})}"; |
| 39 | + @Param({ |
| 40 | + "{fn week({d '2005-01-24'})}" |
| 41 | + , "{fn timestampdiff(SQL_TSI_SECOND,{fn now()},{fn timestampadd(SQL_TSI_SECOND,3,{fn now()})})}" |
| 42 | + , "{fn user()}" |
| 43 | + , "{fn qwer(t,y)}" |
| 44 | + , "{fn concat(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)}"}) |
| 45 | + private String fnEscapeSQL; |
31 | 46 | private boolean replaceProcessingEnabled = true; |
32 | 47 | private boolean standardConformingStrings = false; |
33 | 48 |
|
34 | 49 | @Benchmark |
35 | 50 | public String escapeFunctionWithDate() throws Exception { |
36 | 51 | return Parser.replaceProcessing(fnEscapeSQL, replaceProcessingEnabled, standardConformingStrings); |
37 | 52 | } |
| 53 | + |
| 54 | + public static void main(String[] args) throws RunnerException { |
| 55 | + Options opt = new OptionsBuilder() |
| 56 | + .include(EscapeProcessing.class.getSimpleName()) |
| 57 | + .addProfiler(GCProfiler.class) |
| 58 | + .addProfiler(FlightRecorderProfiler.class) |
| 59 | + .detectJvmArgs() |
| 60 | + .build(); |
| 61 | + |
| 62 | + new Runner(opt).run(); |
| 63 | + } |
38 | 64 | } |
0 commit comments