Skip to content

Commit dbfc947

Browse files
committed
fix junit tests: BenchmarkTests
- fix path to meso/image-magix - fix image-magix success pattern - fix ai-nqueen bench arg in tests
1 parent d7993c7 commit dbfc947

File tree

7 files changed

+66
-48
lines changed

7 files changed

+66
-48
lines changed

graalpython/benchmarks/src/meso/ai-nqueen.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,15 @@ def measure(queen_count):
9999

100100
def __benchmark__(queen_count=10):
101101
measure(queen_count)
102+
103+
104+
if __name__ == '__main__':
105+
import sys
106+
import time
107+
start = time.time()
108+
if len(sys.argv) >= 2:
109+
num = int(sys.argv[1])
110+
__benchmark__(num)
111+
else:
112+
__benchmark__()
113+
print("%s took %s s" % (__file__, time.time() - start))

graalpython/benchmarks/src/meso/image-magix.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,23 @@ def measure(num):
118118
for i in range(num):
119119
img = img.sobel(horizontal=True, vertical=True)
120120
img = img.fisheye(bilinear=True, fraction=3)
121+
return img
122+
121123

122-
123124
def __benchmark__(num=10000):
124-
measure(num)
125+
return measure(num)
126+
127+
128+
if __name__ == '__main__':
129+
import sys
130+
import time
131+
global SZ
132+
SZ = 5
133+
start = time.time()
134+
if len(sys.argv) >= 2:
135+
num = int(sys.argv[1])
136+
img = __benchmark__(num)
137+
else:
138+
img = __benchmark__(2)
139+
print(img.data)
140+
print("%s took %s s" % (__file__, time.time() - start))

graalpython/benchmarks/src/meso/mandelbrot3.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,15 @@ def measure(num):
8989

9090
def __benchmark__(num=4000):
9191
measure(num)
92+
93+
94+
if __name__ == '__main__':
95+
import sys
96+
import time
97+
start = time.time()
98+
if len(sys.argv) >= 2:
99+
num = int(sys.argv[1])
100+
__benchmark__(num)
101+
else:
102+
__benchmark__()
103+
print("%s took %s s" % (__file__, time.time() - start))

graalpython/benchmarks/src/meso/richards3.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,15 @@ def measure(iteration):
445445

446446
def __benchmark__(num=200):
447447
measure(num)
448+
449+
450+
if __name__ == '__main__':
451+
import sys
452+
import time
453+
start = time.time()
454+
if len(sys.argv) >= 2:
455+
num = int(sys.argv[1])
456+
__benchmark__(num)
457+
else:
458+
__benchmark__()
459+
print("%s took %s s" % (__file__, time.time() - start))

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/PythonTests.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,7 @@ public static File getBenchFile(Path filename) {
220220

221221
Path fullPath = Paths.get(path.toString(), filename.toString());
222222
if (!Files.isReadable(fullPath)) {
223-
fullPath = Paths.get(path.toString(), "benchmarks", filename.toString());
224-
if (!Files.isReadable(fullPath)) {
225-
fullPath = Paths.get(path.toString(), "micro", filename.toString());
226-
if (!Files.isReadable(fullPath))
227-
throw new IllegalStateException("Unable to locate " + path + " (benchmarks or micro) " + filename.toString());
228-
}
223+
throw new IllegalStateException("Unable to locate " + path + " (benchmarks or micro) " + filename.toString());
229224
}
230225

231226
File file = new File(fullPath.toString());

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advance/BenchmarkTests.java

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,55 +30,27 @@
3030
import java.nio.file.Path;
3131
import java.nio.file.Paths;
3232

33-
import org.junit.Ignore;
3433
import org.junit.Test;
3534

3635
public class BenchmarkTests {
36+
private static final String BENCH_SUITE_MESO = "meso";
3737

3838
@Test
3939
public void richards3() {
40-
Path script = Paths.get("richards3.py");
41-
assertBenchNoError(script, new String[]{script.toString(), "3"});
40+
Path script = Paths.get(BENCH_SUITE_MESO, "richards3.py");
41+
assertBenchNoError(script, new String[]{script.toString(), "20"});
4242
}
4343

4444
@Test
4545
public void bm_ai() {
46-
Path script = Paths.get("bm-ai.py");
47-
assertBenchNoError(script, new String[]{script.toString(), "0"});
46+
Path script = Paths.get(BENCH_SUITE_MESO, "ai-nqueen.py");
47+
assertBenchNoError(script, new String[]{script.toString(), "5"});
4848
}
4949

5050
@Test
5151
public void mandelbrot3_300() {
52-
Path script = Paths.get("mandelbrot3_noprint.py");
53-
assertBenchNoError(script, new String[]{script.toString(), "300"});
54-
}
55-
56-
@Ignore
57-
@Test
58-
public void simplejson_bench_test() {
59-
Path script = Paths.get("simplejson-bench.py");
60-
assertBenchNoError(script, new String[]{"simplejson-bench.py", "100"});
61-
}
62-
63-
@Ignore
64-
@Test
65-
public void whoosh_bench_test() {
66-
Path script = Paths.get("whoosh-bench.py");
67-
assertBenchNoError(script, new String[]{"whoosh-bench.py", "50"});
68-
}
69-
70-
@Ignore
71-
@Test
72-
public void pymaging_bench_test() {
73-
Path script = Paths.get("pymaging-bench.py");
74-
assertBenchNoError(script, new String[]{"pymaging-bench.py", "50"});
75-
}
76-
77-
@Ignore
78-
@Test
79-
public void sympy_bench_test() {
80-
Path script = Paths.get("sympy-bench.py");
81-
assertBenchNoError(script, new String[]{"sympy-bench.py", "200"});
52+
Path script = Paths.get(BENCH_SUITE_MESO, "mandelbrot3.py");
53+
assertBenchNoError(script, new String[]{script.toString(), "200"});
8254
}
8355

8456
}

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import platform
2626
import re
2727
import shutil
28-
import subprocess
2928
import sys
3029
import tempfile
3130
from argparse import ArgumentParser
@@ -37,6 +36,7 @@
3736
import mx_subst
3837
import mx_urlrewrites
3938
from mx_gate import Task
39+
from mx_graalpython_bench_param import PATH_MESO
4040
from mx_graalpython_benchmark import PythonBenchmarkSuite
4141
from mx_unittest import unittest
4242

@@ -413,17 +413,16 @@ def is_included(path):
413413
with Task('GraalPython GraalVM build', tasks, tags=[GraalPythonTags.downstream, GraalPythonTags.graalvm]) as task:
414414
if task:
415415
svm_image = python_svm(["--version"])
416-
benchmark = os.path.join("graalpython", "benchmarks", "src", "benchmarks", "image_magix.py")
416+
benchmark = os.path.join(PATH_MESO, "image-magix.py")
417417
out = mx.OutputCapture()
418418
mx.run(
419419
[svm_image, benchmark],
420420
nonZeroIsFatal=True,
421421
out=mx.TeeOutputCapture(out)
422422
)
423423
success = "\n".join([
424-
"[0, 0, 0, 0, 0, 0, 20, 20, 20, 0, 0, 20, 20, 20, 0, 0, 20, 20, 20, 0, 0, 0, 0, 0, 0]",
425-
"[11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, 51, 52, 53, 54, 55]",
426-
"[11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 36, 36, 35, 41, 41, 40, 40, 45, 51, 52, 53, 54, 55]"])
424+
"[0, 0, 0, 0, 0, 0, 10, 10, 10, 0, 0, 10, 3, 10, 0, 0, 10, 10, 10, 0, 0, 0, 0, 0, 0]",
425+
])
427426
if success not in out.data:
428427
mx.abort('Output from generated SVM image "' + svm_image + '" did not match success pattern:\n' + success)
429428

0 commit comments

Comments
 (0)