1 # Copyright (c) 2024, 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,premain custom static CDS only,premain CDS + AOT" | 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= runs    2>&1 | grep Booted >> tmp.txt; \
41 		$(SLEEP) $(MAKE) LOG_INIT= runn    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 	@${MAINLINE_JAVA} ../lib/GithubMDChart.java mainline_vs_premain.md < mainline_vs_premain.csv
48 
49 # Compare two premain builds running "make run"
50 #
51 # make PM_OLD=/repos/leyden_old/build/linux-x64/images/jdk \
52 #      PM_NEW=/repos/leyden_new/build/linux-x64/images/jdk \
53 #      BLDJDK_HOME=/usr/local/jdk21 \
54 #      compare_premain_builds
55 #
56 # Note: you can also use the same build, but use different option to enable/disable certain features. E.g.
57 #
58 # make PM_OLD=/repo/leyden/build/linux-x64/images/jdk PM_OPTS_NEW=-XX:-ArchivePackages \
59 #      PM_NEW=/repo/leyden/build/linux-x64/images/jdk PM_OPTS_NEW=-XX:+ArchivePackages \
60 #      BLDJDK_HOME=/my/jdk/21/home
61 #      compare_premain_builds
62 #
63 # Or .. to benchmark a feature that you're developing
64 #
65 # make PM_OLD=/repos/leyden/build/linux-x64/images/jdk PM_OPTS_OLD="-XX:+UnlockDiagnosticVMOptions -XX:-UseNewCode" \
66 #      PM_NEW=/repos/leyden/build/linux-x64/images/jdk PM_OPTS_NEW="-XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode" \
67 #      BLDJDK_HOME=/usr/local/jdk21 \
68 #      compare_premain_builds
69 #
70 
71 compare_premain_builds: clean0 _compare_premain_builds
72 
73 _compare_premain_builds:
74 	@rm -f compare_premain_builds.csv
75 	@echo Old build = ${PM_OLD} with options ${PM_OPTS_OLD}
76 	@echo New build = ${PM_NEW} with options ${PM_OPTS_NEW}
77 	@echo "Run,Old CDS + AOT,New CDS + AOT" | tee -a compare_premain_builds.csv
78 	@first=1; for i in ${LOOPS}; do \
79 		rm -f tmp.txt; \
80 		$(SLEEP) $(MAKE) LOG_INIT= PREMAIN_HOME=${PM_OLD} PM_VER=.old PM_OPTS="${PM_OPTS_OLD}" runn 2>&1 | grep Booted >> tmp.txt; \
81 		$(SLEEP) $(MAKE) LOG_INIT= PREMAIN_HOME=${PM_NEW} PM_VER=.new PM_OPTS="${PM_OPTS_NEW}" runn 2>&1 | grep Booted >> tmp.txt; \
82 		if test "$$first" != "1"; then \
83 		    echo $$i$$(cat tmp.txt | sed -e 's/.*in /,/g' -e 's/ms//g') | sed -e 's/ //g' | tee -a compare_premain_builds.csv; \
84 	        fi; \
85 		first=0; \
86 	done
87 	@${MAINLINE_JAVA} ../lib/GithubMDChart.java compare_premain_builds.md < compare_premain_builds.csv