Expanding tests and eval infra

This commit is contained in:
Gunnar Morling 2024-01-04 17:22:00 +01:00
parent a503362c36
commit b6d33fd8fe
11 changed files with 104 additions and 3 deletions

View File

@ -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.

View File

@ -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
View 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())));
}
}

View 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}

View 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

View File

@ -0,0 +1 @@
{Bosaso=-15.0/1.3/20.5, Petropavlovsk-Kamchatsky=-9.5/0.0/9.5}

View 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

View File

@ -0,0 +1 @@
{Bosaso=-99.9/-99.9/-99.9, Petropavlovsk-Kamchatsky=99.9/99.9/99.9}

View File

@ -0,0 +1,2 @@
Bosaso;-99.9
Petropavlovsk-Kamchatsky;99.9

View File

@ -31,6 +31,6 @@ do
rm -f measurements.txt
ln -s $sample measurements.txt
diff <(./calculate_average.sh) ${sample%.txt}.out
diff <("./calculate_average_$1.sh") ${sample%.txt}.out
done
rm measurements.txt