Skip to content
This repository was archived by the owner on Aug 6, 2022. It is now read-only.

Commit 2a4ce35

Browse files
committed
feat: add more cases to EscapeProcessing
1 parent 4366947 commit 2a4ce35

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/main/java/org/postgresql/benchmark/escaping/EscapeProcessing.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@
55

66
package org.postgresql.benchmark.escaping;
77

8+
import org.postgresql.benchmark.profilers.FlightRecorderProfiler;
89
import org.postgresql.core.Parser;
910

1011
import org.openjdk.jmh.annotations.Benchmark;
1112
import org.openjdk.jmh.annotations.BenchmarkMode;
13+
import org.openjdk.jmh.annotations.Fork;
1214
import org.openjdk.jmh.annotations.Measurement;
1315
import org.openjdk.jmh.annotations.Mode;
1416
import org.openjdk.jmh.annotations.OutputTimeUnit;
17+
import org.openjdk.jmh.annotations.Param;
1518
import org.openjdk.jmh.annotations.Scope;
1619
import org.openjdk.jmh.annotations.State;
1720
import org.openjdk.jmh.annotations.Threads;
1821
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;
1927

2028
import java.util.concurrent.TimeUnit;
2129

30+
@Fork(value = 5, jvmArgsPrepend = "-Xmx128m")
2231
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
2332
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
2433
@State(Scope.Thread)
@@ -27,12 +36,29 @@
2736
@OutputTimeUnit(TimeUnit.NANOSECONDS)
2837
public class EscapeProcessing {
2938

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;
3146
private boolean replaceProcessingEnabled = true;
3247
private boolean standardConformingStrings = false;
3348

3449
@Benchmark
3550
public String escapeFunctionWithDate() throws Exception {
3651
return Parser.replaceProcessing(fnEscapeSQL, replaceProcessingEnabled, standardConformingStrings);
3752
}
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+
}
3864
}

0 commit comments

Comments
 (0)