Skip to content

Commit aadbe15

Browse files
committed
Extend JMH benchmarks with complex mapping.
Based on the Limetrans Alma mapping. Adds some Alma test records (`alma-small` = 121 records).
1 parent 6878e0b commit aadbe15

23 files changed

+19084
-57
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ project(':metafacture-runner') {
9696
// '**/bin',
9797
// '**/generated',
9898
// '**/includeBenchmark*100000/expected.json',
99+
// '**/jmh/resources/**/input',
99100
// '**/node_modules',
100101
// '**/out',
101102
// '**/output-*',

metafix/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ jmhJar {
7373
exclude '/org/slf4j/impl/StaticLoggerBinder.class'
7474
}
7575

76+
jmh {
77+
if (project.hasProperty('include')) {
78+
includes = project.getProperty('include').split() as List
79+
}
80+
81+
if (project.hasProperty('exclude')) {
82+
excludes = project.getProperty('exclude').split() as List
83+
}
84+
85+
def systemProperties = [:]
86+
passSystemProperties(systemProperties)
87+
jvmArgsAppend = systemProperties.collect { k, v -> "-D${k}=${v}" }
88+
}
89+
7690
test {
7791
useJUnitPlatform()
7892

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2025 hbz NRW
3+
*
4+
* Licensed under the Apache License, Version 2.0 the "License";
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.metafacture.metafix;
18+
19+
import org.metafacture.framework.helpers.DefaultStreamReceiver;
20+
import org.metafacture.io.FileOpener;
21+
import org.metafacture.io.ObjectStdoutWriter;
22+
import org.metafacture.io.RecordReader;
23+
import org.metafacture.json.JsonDecoder;
24+
import org.metafacture.json.JsonEncoder;
25+
26+
import java.io.IOException;
27+
import java.io.UncheckedIOException;
28+
29+
public abstract class AbstractMetafixBenchmark extends FixParseBenchmark { // checkstyle-disable-line ClassDataAbstractionCoupling
30+
31+
// TODO: Need to inject system properties into JMHTask's JavaExec process.
32+
//private static final boolean DEBUG_OUTPUT = Boolean.parseBoolean(System.getProperty("org.metafacture.metafix.debugBenchmarkOutput"));
33+
private static final boolean DEBUG_OUTPUT = false;
34+
35+
private static final String INPUT = BASE + "/input/%s.json";
36+
37+
private FileOpener fileOpener;
38+
private String inputFile;
39+
40+
/**
41+
* Creates an instance of {@link AbstractMetafixBenchmark}.
42+
*/
43+
public AbstractMetafixBenchmark() {
44+
}
45+
46+
@Override
47+
public void setup() {
48+
super.setup();
49+
50+
inputFile = String.format(INPUT, getInput());
51+
52+
final Metafix metafix;
53+
try {
54+
metafix = new Metafix(getFixFile());
55+
}
56+
catch (final IOException e) {
57+
throw new UncheckedIOException(e);
58+
}
59+
60+
if (DEBUG_OUTPUT) {
61+
metafix
62+
.setReceiver(new JsonEncoder())
63+
.setReceiver(new ObjectStdoutWriter<String>());
64+
}
65+
else {
66+
metafix
67+
.setReceiver(new DefaultStreamReceiver());
68+
}
69+
70+
fileOpener = new FileOpener();
71+
fileOpener
72+
.setReceiver(new RecordReader())
73+
.setReceiver(new JsonDecoder())
74+
.setReceiver(metafix);
75+
}
76+
77+
@Override
78+
protected void workload() {
79+
fileOpener.process(inputFile);
80+
}
81+
82+
protected abstract String getInput();
83+
84+
}

metafix/src/jmh/java/org/metafacture/metafix/FixParseBenchmark.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ public class FixParseBenchmark extends AbstractBenchmark {
2525

2626
private static final String FIXES = BASE + "/fixes/%s" + Metafix.FIX_EXTENSION;
2727

28-
protected String fixFile; // checkstyle-disable-line VisibilityModifier
28+
private String fixFile;
2929

3030
@Param({ // checkstyle-disable-line AnnotationUseStyle
31-
"nothing"
31+
"nothing",
32+
"alma"
3233
})
3334
private String fixDef;
3435

@@ -48,7 +49,11 @@ public void setup() {
4849

4950
@Override
5051
protected void workload() {
51-
FixStandaloneSetup.parseFix(fixFile);
52+
FixStandaloneSetup.parseFix(getFixFile());
53+
}
54+
55+
protected String getFixFile() {
56+
return fixFile;
5257
}
5358

5459
}

metafix/src/jmh/java/org/metafacture/metafix/MetafixBenchmark.java

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,13 @@
1616

1717
package org.metafacture.metafix;
1818

19-
import org.metafacture.framework.helpers.DefaultStreamReceiver;
20-
import org.metafacture.io.FileOpener;
21-
import org.metafacture.io.ObjectStdoutWriter;
22-
import org.metafacture.io.RecordReader;
23-
import org.metafacture.json.JsonDecoder;
24-
import org.metafacture.json.JsonEncoder;
25-
2619
import org.openjdk.jmh.annotations.Param;
2720

28-
import java.io.IOException;
29-
import java.io.UncheckedIOException;
30-
31-
public class MetafixBenchmark extends FixParseBenchmark { // checkstyle-disable-line ClassDataAbstractionCoupling
32-
33-
// TODO: Need to inject system properties into JMHTask's JavaExec process.
34-
//private static final boolean DEBUG_OUTPUT = Boolean.parseBoolean(System.getProperty("org.metafacture.metafix.debugBenchmarkOutput"));
35-
private static final boolean DEBUG_OUTPUT = false;
36-
37-
private static final String INPUT = BASE + "/input/%s.json";
38-
39-
private FileOpener fileOpener;
40-
private String inputFile;
21+
public class MetafixBenchmark extends AbstractMetafixBenchmark {
4122

4223
@Param({ // checkstyle-disable-line AnnotationUseStyle
43-
"empty"
24+
"empty",
25+
"alma-small"
4426
})
4527
private String input;
4628

@@ -51,39 +33,8 @@ public MetafixBenchmark() {
5133
}
5234

5335
@Override
54-
public void setup() {
55-
super.setup();
56-
57-
inputFile = String.format(INPUT, input);
58-
59-
final Metafix metafix;
60-
try {
61-
metafix = new Metafix(fixFile);
62-
}
63-
catch (final IOException e) {
64-
throw new UncheckedIOException(e);
65-
}
66-
67-
if (DEBUG_OUTPUT) {
68-
metafix
69-
.setReceiver(new JsonEncoder())
70-
.setReceiver(new ObjectStdoutWriter<String>());
71-
}
72-
else {
73-
metafix
74-
.setReceiver(new DefaultStreamReceiver());
75-
}
76-
77-
fileOpener = new FileOpener();
78-
fileOpener
79-
.setReceiver(new RecordReader())
80-
.setReceiver(new JsonDecoder())
81-
.setReceiver(metafix);
82-
}
83-
84-
@Override
85-
protected void workload() {
86-
fileOpener.process(inputFile);
36+
protected String getInput() {
37+
return input;
8738
}
8839

8940
}

0 commit comments

Comments
 (0)