1 # Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 #
4 # This code is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License version 2 only, as
6 # published by the Free Software Foundation.
7 #
8 # This code is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 # version 2 for more details (a copy is included in the LICENSE file that
12 # accompanied this code).
13 #
14 # You should have received a copy of the GNU General Public License version
15 # 2 along with this work; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 #
18 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 # or visit www.oracle.com if you need additional information or have any
20 # questions.
21
22
23 # You can choose a different number of loops like this:
24 # make compare_premain_builds LOOPS="0 1 2" PM_OLD=.....
25
26 LOOPS = 0 1 2 3 4 5 6 7 8 9 10
27 SLEEP = sleep 1;
28
29 bench: mainline_vs_premain
30
31 mainline_vs_premain: clean0 _mainline_vs_premain
32
33 _mainline_vs_premain:
34 rm -f mainline_vs_premain.csv
35 @echo "run,mainline default,mainline custom static cds,mainline aot cache,premain aot cache" | tee -a mainline_vs_premain.csv
36 @first=1; for i in ${LOOPS}; do \
37 rm -f tmp.txt; \
38 $(SLEEP) $(MAKE) LOG_INIT= run0.ml 2>&1 | grep Booted >> tmp.txt; \
39 $(SLEEP) $(MAKE) LOG_INIT= runs.ml 2>&1 | grep Booted >> tmp.txt; \
40 $(SLEEP) $(MAKE) LOG_INIT= runa.ml 2>&1 | grep Booted >> tmp.txt; \
41 $(SLEEP) $(MAKE) LOG_INIT= runa 2>&1 | grep Booted >> tmp.txt; \
42 if test "$$first" != "1"; then \
43 echo $$i$$(cat tmp.txt | sed -e 's/.*in /,/g' -e 's/ms//g') | sed -e 's/ //g' | tee -a mainline_vs_premain.csv; \
44 fi; \
45 first=0; \
46 done
47 @rm -f tmp.txt
48 @${MAINLINE_JAVA} ../lib/GithubMDChart.java mainline_vs_premain.md < mainline_vs_premain.csv
49
50 # Compare two premain builds running "make run"
51 #
52 # make PM_OLD=/repos/leyden_old/build/linux-x64/images/jdk \
53 # PM_NEW=/repos/leyden_new/build/linux-x64/images/jdk \
54 # BLDJDK_HOME=/usr/local/jdk21 \
55 # compare_premain_builds
56 #
57 # Note: you can also use the same build, but use different option to enable/disable certain features. E.g.
58 #
59 # make PM_OLD=/repo/leyden/build/linux-x64/images/jdk PM_OPTS_NEW=-XX:-ArchivePackages \
60 # PM_NEW=/repo/leyden/build/linux-x64/images/jdk PM_OPTS_NEW=-XX:+ArchivePackages \
61 # BLDJDK_HOME=/my/jdk/21/home
62 # compare_premain_builds
63 #
64 # Or .. to benchmark a feature that you're developing
65 #
66 # make PM_OLD=/repos/leyden/build/linux-x64/images/jdk PM_OPTS_OLD="-XX:+UnlockDiagnosticVMOptions -XX:-UseNewCode" \
67 # PM_NEW=/repos/leyden/build/linux-x64/images/jdk PM_OPTS_NEW="-XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode" \
68 # BLDJDK_HOME=/usr/local/jdk21 \
69 # compare_premain_builds
70 #
71
72 compare_premain_builds: clean0 _compare_premain_builds
73
74 _compare_premain_builds:
75 @rm -f compare_premain_builds.csv
76 @echo Old build = ${PM_OLD} with options ${PM_OPTS_OLD}
77 @echo New build = ${PM_NEW} with options ${PM_OPTS_NEW}
78 @echo "Run,Old CDS + AOT,New CDS + AOT" | tee -a compare_premain_builds.csv
79 @first=1; for i in ${LOOPS}; do \
80 rm -f tmp.txt; \
81 $(SLEEP) $(MAKE) LOG_INIT= PREMAIN_HOME=${PM_OLD} PM_VER=.old PM_OPTS="${PM_OPTS_OLD}" runa 2>&1 | grep Booted >> tmp.txt; \
82 $(SLEEP) $(MAKE) LOG_INIT= PREMAIN_HOME=${PM_NEW} PM_VER=.new PM_OPTS="${PM_OPTS_NEW}" runa 2>&1 | grep Booted >> tmp.txt; \
83 if test "$$first" != "1"; then \
84 echo $$i$$(cat tmp.txt | sed -e 's/.*in /,/g' -e 's/ms//g') | sed -e 's/ //g' | tee -a compare_premain_builds.csv; \
85 fi; \
86 first=0; \
87 done
88 @rm -f tmp.txt
89 @${MAINLINE_JAVA} ../lib/GithubMDChart.java compare_premain_builds.md < compare_premain_builds.csv