Skip to content

Commit 0a9d1ad

Browse files
author
Andrija Kolic
committed
Adjust the benchmark files to the PolyBench contract.
1 parent e000ada commit 0a9d1ad

10 files changed

Lines changed: 427 additions & 134 deletions

File tree

graalpython/com.oracle.graal.python.benchmarks/python/matplotlib/3d_surface_wireframe.py

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,62 @@
11
#!/usr/bin/env python3
2+
# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# The Universal Permissive License (UPL), Version 1.0
6+
#
7+
# Subject to the condition set forth below, permission is hereby granted to any
8+
# person obtaining a copy of this software, associated documentation and/or
9+
# data (collectively the "Software"), free of charge and under any and all
10+
# copyright rights in the Software, and any and all patent rights owned or
11+
# freely licensable by each licensor hereunder covering either (i) the
12+
# unmodified Software as contributed to or provided by such licensor, or (ii)
13+
# the Larger Works (as defined below), to deal in both
14+
#
15+
# (a) the Software, and
16+
#
17+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
# one is included with the Software each a "Larger Work" to which the Software
19+
# is contributed by such licensors),
20+
#
21+
# without restriction, including without limitation the rights to copy, create
22+
# derivative works of, display, perform, and distribute the Software and make,
23+
# use, sell, offer for sale, import, export, have made, and have sold the
24+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
# either these or other terms.
26+
#
27+
# This license is subject to the following condition:
28+
#
29+
# The above copyright notice and either this complete permission notice or at a
30+
# minimum a reference to the UPL must be included in all copies or substantial
31+
# portions of the Software.
32+
#
33+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
# SOFTWARE.
40+
241
"""
342
3D plotting example: surface, wireframe, and contour projections.
443
Saves to PDF.
5-
6-
Run:
7-
python tst/3d_surface_wireframe.py
844
"""
945

10-
from pathlib import Path
11-
12-
# Use a non-interactive backend to work in headless environments
13-
import matplotlib
14-
matplotlib.use("Agg")
1546

16-
import matplotlib.pyplot as plt
17-
import numpy as np
18-
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 # needed for 3D projection
47+
def run():
48+
# Execute all imports inside the `run` method so they're measured
49+
from pathlib import Path
50+
# Use a non-interactive backend to work in headless environments
51+
import matplotlib
52+
matplotlib.use("Agg")
53+
import matplotlib.pyplot as plt
54+
import numpy as np
1955

56+
# Ensure we have version info in the logs
57+
print(f"Using matplotlib version '{matplotlib.__version__}'")
58+
print(f"Using numpy version '{np.__version__}'")
2059

21-
def main() -> None:
2260
out_path = Path(__file__).parent / "surface_3d.pdf"
2361

2462
# Domain and function
@@ -72,8 +110,18 @@ def main() -> None:
72110
fig.savefig(out_path, format="pdf")
73111
plt.close(fig)
74112

75-
print(f"Wrote PDF: {out_path.resolve()}")
113+
114+
def warmupIterations():
115+
return 0
116+
117+
118+
def iterations():
119+
return 1
76120

77121

78-
if __name__ == "__main__":
79-
main()
122+
def summary():
123+
return {
124+
"name": "OutlierRemovalAverageSummary",
125+
"lower-threshold": 0.0,
126+
"upper-threshold": 1.0,
127+
}

graalpython/com.oracle.graal.python.benchmarks/python/matplotlib/categorical_bar_and_box.py

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
#!/usr/bin/env python3
2+
# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# The Universal Permissive License (UPL), Version 1.0
6+
#
7+
# Subject to the condition set forth below, permission is hereby granted to any
8+
# person obtaining a copy of this software, associated documentation and/or
9+
# data (collectively the "Software"), free of charge and under any and all
10+
# copyright rights in the Software, and any and all patent rights owned or
11+
# freely licensable by each licensor hereunder covering either (i) the
12+
# unmodified Software as contributed to or provided by such licensor, or (ii)
13+
# the Larger Works (as defined below), to deal in both
14+
#
15+
# (a) the Software, and
16+
#
17+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
# one is included with the Software each a "Larger Work" to which the Software
19+
# is contributed by such licensors),
20+
#
21+
# without restriction, including without limitation the rights to copy, create
22+
# derivative works of, display, perform, and distribute the Software and make,
23+
# use, sell, offer for sale, import, export, have made, and have sold the
24+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
# either these or other terms.
26+
#
27+
# This license is subject to the following condition:
28+
#
29+
# The above copyright notice and either this complete permission notice or at a
30+
# minimum a reference to the UPL must be included in all copies or substantial
31+
# portions of the Software.
32+
#
33+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
# SOFTWARE.
40+
241
"""
342
Categorical plots: grouped bar chart with error bars and a boxplot.
443
Saves a multi-page PDF using PdfPages.
5-
6-
Run:
7-
python tst/categorical_bar_and_box.py
844
"""
945

10-
from pathlib import Path
11-
12-
# Use a non-interactive backend to work in headless environments
13-
import matplotlib
14-
matplotlib.use("Agg")
15-
16-
import matplotlib.pyplot as plt
17-
import numpy as np
18-
from matplotlib.backends.backend_pdf import PdfPages
19-
2046

2147
def _colorize_boxplot(bp, facecolor="#1f77b4", edgecolor="black", alpha=0.6):
2248
for box in bp["boxes"]:
@@ -31,7 +57,20 @@ def _colorize_boxplot(bp, facecolor="#1f77b4", edgecolor="black", alpha=0.6):
3157
flier.set(marker="o", markersize=3, markerfacecolor="white", markeredgecolor=edgecolor, alpha=0.7)
3258

3359

34-
def main() -> None:
60+
def run():
61+
# Execute all imports inside the `run` method so they're measured
62+
from pathlib import Path
63+
# Use a non-interactive backend to work in headless environments
64+
import matplotlib
65+
matplotlib.use("Agg")
66+
import matplotlib.pyplot as plt
67+
import numpy as np
68+
from matplotlib.backends.backend_pdf import PdfPages
69+
70+
# Ensure we have version info in the logs
71+
print(f"Using matplotlib version '{matplotlib.__version__}'")
72+
print(f"Using numpy version '{np.__version__}'")
73+
3574
out_path = Path(__file__).parent / "categorical_plots.pdf"
3675

3776
rng = np.random.default_rng(2024)
@@ -81,7 +120,7 @@ def main() -> None:
81120
fig2, ax2 = plt.subplots(figsize=(7, 4), dpi=150)
82121
bp = ax2.boxplot(
83122
data,
84-
tick_labels=categories,
123+
labels=categories,
85124
widths=0.6,
86125
patch_artist=True,
87126
showfliers=True,
@@ -110,8 +149,18 @@ def main() -> None:
110149
pdf.savefig(fig2)
111150
plt.close(fig2)
112151

113-
print(f"Wrote PDF: {out_path.resolve()}")
152+
153+
def warmupIterations():
154+
return 0
155+
156+
157+
def iterations():
158+
return 1
114159

115160

116-
if __name__ == "__main__":
117-
main()
161+
def summary():
162+
return {
163+
"name": "OutlierRemovalAverageSummary",
164+
"lower-threshold": 0.0,
165+
"upper-threshold": 1.0,
166+
}

graalpython/com.oracle.graal.python.benchmarks/python/matplotlib/distributions_hist_2d.py

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,61 @@
11
#!/usr/bin/env python3
2+
# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# The Universal Permissive License (UPL), Version 1.0
6+
#
7+
# Subject to the condition set forth below, permission is hereby granted to any
8+
# person obtaining a copy of this software, associated documentation and/or
9+
# data (collectively the "Software"), free of charge and under any and all
10+
# copyright rights in the Software, and any and all patent rights owned or
11+
# freely licensable by each licensor hereunder covering either (i) the
12+
# unmodified Software as contributed to or provided by such licensor, or (ii)
13+
# the Larger Works (as defined below), to deal in both
14+
#
15+
# (a) the Software, and
16+
#
17+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
# one is included with the Software each a "Larger Work" to which the Software
19+
# is contributed by such licensors),
20+
#
21+
# without restriction, including without limitation the rights to copy, create
22+
# derivative works of, display, perform, and distribute the Software and make,
23+
# use, sell, offer for sale, import, export, have made, and have sold the
24+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
# either these or other terms.
26+
#
27+
# This license is subject to the following condition:
28+
#
29+
# The above copyright notice and either this complete permission notice or at a
30+
# minimum a reference to the UPL must be included in all copies or substantial
31+
# portions of the Software.
32+
#
33+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
# SOFTWARE.
40+
241
"""
342
Distribution plots: 1D histogram, 2D histogram, and hexbin with colorbars.
4-
5-
Run:
6-
python tst/distributions_hist_2d.py
743
"""
844

9-
from pathlib import Path
10-
11-
# Use a non-interactive backend to work in headless environments
12-
import matplotlib
13-
matplotlib.use("Agg")
1445

15-
import matplotlib.pyplot as plt
16-
import numpy as np
46+
def run():
47+
# Execute all imports inside the `run` method so they're measured
48+
from pathlib import Path
49+
# Use a non-interactive backend to work in headless environments
50+
import matplotlib
51+
matplotlib.use("Agg")
52+
import matplotlib.pyplot as plt
53+
import numpy as np
1754

55+
# Ensure we have version info in the logs
56+
print(f"Using matplotlib version '{matplotlib.__version__}'")
57+
print(f"Using numpy version '{np.__version__}'")
1858

19-
def main() -> None:
2059
out_path = Path(__file__).parent / "distributions_2d.pdf"
2160

2261
rng = np.random.default_rng(7)
@@ -66,8 +105,18 @@ def main() -> None:
66105
fig.savefig(out_path, format="pdf")
67106
plt.close(fig)
68107

69-
print(f"Wrote PDF: {out_path.resolve()}")
108+
109+
def warmupIterations():
110+
return 0
111+
112+
113+
def iterations():
114+
return 1
70115

71116

72-
if __name__ == "__main__":
73-
main()
117+
def summary():
118+
return {
119+
"name": "OutlierRemovalAverageSummary",
120+
"lower-threshold": 0.0,
121+
"upper-threshold": 1.0,
122+
}

0 commit comments

Comments
 (0)