Expanding tests and eval infra
This commit is contained in:
parent
a503362c36
commit
b6d33fd8fe
@ -63,7 +63,7 @@ See [below](#entering-the-challenge) for instructions how to enter the challenge
|
||||
This repository contains two programs:
|
||||
|
||||
* `dev.morling.onebrc.CreateMeasurements` (invoked via _create\_measurements.sh_): Creates the file _measurements.txt_ in the root directory of this project with a configurable number of random measurement values
|
||||
* `dev.morling.onebrc.CalculateAverage` (invoked via _calculate\_average.sh_): Calculates the average values for the file _measurements.txt_
|
||||
* `dev.morling.onebrc.CalculateAverage` (invoked via _calculate\_average\_baseline.sh_): Calculates the average values for the file _measurements.txt_
|
||||
|
||||
Execute the following steps to run the challenge:
|
||||
|
||||
@ -133,7 +133,7 @@ To submit your own implementation to 1BRC, follow these steps:
|
||||
* Create a fork of the [onebrc](https://github.com/gunnarmorling/onebrc/) GitHub repository.
|
||||
* Create a copy of _CalculateAverage.java_, named _CalculateAverage\_<your_GH_user>.java_, e.g. _CalculateAverage\_doloreswilson.java_.
|
||||
* Make that implementation fast. Really fast.
|
||||
* Create a copy of _calculate_average.sh_, named _calculate\_average\_<your_GH_user>.sh_, e.g. _calculate\_average\_doloreswilson.sh_.
|
||||
* Create a copy of _calculate_average_baseline.sh_, named _calculate\_average\_<your_GH_user>.sh_, e.g. _calculate\_average\_doloreswilson.sh_.
|
||||
* Adjust that script so that it references your implementation class name. If needed, provide any JVM arguments via the `JAVA_OPTS` variable in that script.
|
||||
* OpenJDK 21 is the default. If a custom JDK build is required, include the SDKMAN command `sdk use java [version]` in the launch shell script prior to application start.
|
||||
* (Optional) If you'd like to use native binaries (GraalVM), adjust the _pom.xml_ file so that it builds that binary.
|
||||
|
@ -25,6 +25,9 @@ java --version
|
||||
|
||||
mvn clean verify
|
||||
|
||||
rm -f measurements.txt
|
||||
ln -s measurements_1B.txt measurements.txt
|
||||
|
||||
for i in {1..5}
|
||||
do
|
||||
./calculate_average_$1.sh
|
||||
|
67
process_output.java
Normal file
67
process_output.java
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2023 The original authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class process_output {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
String expectedFile = args[0];
|
||||
String actualFile = args[1];
|
||||
|
||||
String expected = new String(Files.readAllBytes(Paths.get(expectedFile)));
|
||||
List<String> times = new ArrayList<>();
|
||||
|
||||
var outputLines = Files.lines(Paths.get(actualFile))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int matched = 0;
|
||||
|
||||
for (String line : outputLines) {
|
||||
if (line.contains("Hamburg")) {
|
||||
if (!line.equals(expected)) {
|
||||
System.err.println("FAILURE Unexpected output");
|
||||
System.err.println(line);
|
||||
}
|
||||
else {
|
||||
matched++;
|
||||
}
|
||||
}
|
||||
else if (line.startsWith("real")) {
|
||||
times.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (matched == 5) {
|
||||
System.out.println("OK Output matched");
|
||||
}
|
||||
else {
|
||||
System.err.println("FAILURE Output didn't match");
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println(actualFile);
|
||||
|
||||
System.out.println(times.stream()
|
||||
.map(t -> t.substring(5))
|
||||
.map(t -> t.replace("s", "").replace("m", ":"))
|
||||
.collect(Collectors.joining(System.lineSeparator())));
|
||||
}
|
||||
}
|
1
src/test/resources/samples/measurements-20.out
Normal file
1
src/test/resources/samples/measurements-20.out
Normal file
@ -0,0 +1 @@
|
||||
{Abéché1️⃣🐝🏎️=27.3/27.3/27.3, Almaty1️⃣🐝🏎️=15.3/15.3/15.3, Baghdad1️⃣🐝🏎️=26.0/26.0/26.0, Bangkok1️⃣🐝🏎️=25.6/25.6/25.6, Berlin1️⃣🐝🏎️=-0.3/-0.3/-0.3, Birao1️⃣🐝🏎️=33.5/33.5/33.5, Canberra1️⃣🐝🏎️=5.2/5.2/5.2, Chittagong1️⃣🐝🏎️=12.6/12.6/12.6, Da Nang1️⃣🐝🏎️=33.7/33.7/33.7, Edinburgh1️⃣🐝🏎️=19.8/19.8/19.8, Irkutsk1️⃣🐝🏎️=9.9/9.9/9.9, Lhasa1️⃣🐝🏎️=13.4/13.4/13.4, Lyon1️⃣🐝🏎️=1.8/1.8/1.8, Mogadishu1️⃣🐝🏎️=11.5/11.5/11.5, Nashville1️⃣🐝🏎️=-4.9/-4.9/-4.9, Odesa1️⃣🐝🏎️=6.5/6.5/6.5, Parakou1️⃣🐝🏎️=36.3/36.3/36.3, Tamanrasset1️⃣🐝🏎️=17.9/17.9/17.9, Tirana1️⃣🐝🏎️=27.7/27.7/27.7, Xi'an1️⃣🐝🏎️=17.5/17.5/17.5}
|
20
src/test/resources/samples/measurements-20.txt
Normal file
20
src/test/resources/samples/measurements-20.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Odesa1️⃣🐝🏎️;6.5
|
||||
Canberra1️⃣🐝🏎️;5.2
|
||||
Lhasa1️⃣🐝🏎️;13.4
|
||||
Edinburgh1️⃣🐝🏎️;19.8
|
||||
Da Nang1️⃣🐝🏎️;33.7
|
||||
Xi'an1️⃣🐝🏎️;17.5
|
||||
Berlin1️⃣🐝🏎️;-0.3
|
||||
Tamanrasset1️⃣🐝🏎️;17.9
|
||||
Abéché1️⃣🐝🏎️;27.3
|
||||
Baghdad1️⃣🐝🏎️;26.0
|
||||
Lyon1️⃣🐝🏎️;1.8
|
||||
Mogadishu1️⃣🐝🏎️;11.5
|
||||
Bangkok1️⃣🐝🏎️;25.6
|
||||
Irkutsk1️⃣🐝🏎️;9.9
|
||||
Parakou1️⃣🐝🏎️;36.3
|
||||
Almaty1️⃣🐝🏎️;15.3
|
||||
Birao1️⃣🐝🏎️;33.5
|
||||
Chittagong1️⃣🐝🏎️;12.6
|
||||
Tirana1️⃣🐝🏎️;27.7
|
||||
Nashville1️⃣🐝🏎️;-4.9
|
1
src/test/resources/samples/measurements-3.out
Normal file
1
src/test/resources/samples/measurements-3.out
Normal file
@ -0,0 +1 @@
|
||||
{Bosaso=-15.0/1.3/20.5, Petropavlovsk-Kamchatsky=-9.5/0.0/9.5}
|
6
src/test/resources/samples/measurements-3.txt
Normal file
6
src/test/resources/samples/measurements-3.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Bosaso;5.0
|
||||
Bosaso;20.0
|
||||
Bosaso;-5.0
|
||||
Bosaso;-15.0
|
||||
Petropavlovsk-Kamchatsky;9.5
|
||||
Petropavlovsk-Kamchatsky;-9.5
|
1
src/test/resources/samples/measurements-boundaries.out
Normal file
1
src/test/resources/samples/measurements-boundaries.out
Normal file
@ -0,0 +1 @@
|
||||
{Bosaso=-99.9/-99.9/-99.9, Petropavlovsk-Kamchatsky=99.9/99.9/99.9}
|
2
src/test/resources/samples/measurements-boundaries.txt
Normal file
2
src/test/resources/samples/measurements-boundaries.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Bosaso;-99.9
|
||||
Petropavlovsk-Kamchatsky;99.9
|
Loading…
Reference in New Issue
Block a user