1 # Copyright (c) 2023, 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 cd ~/tmp/
23 mkdir -p pet-clinic-bench
24 cd pet-clinic-bench
25 
26 function geomean () {
27     (for i in $*; do echo $i; done) | \
28         awk 'BEGIN{E = exp(1);} $1>0{tot+=log($1); c++} END{m=tot/c; printf "%.2f\n", E^m}' -
29 }
30 
31 function stdev () {
32     (for i in $*; do echo $i; done) | \
33         awk '{for(i=1;i<=NF;i++) {sum[i] += $i; sumsq[i] += ($i)^2}}
34           END {for (i=1;i<=NF;i++) {
35           printf "%.2f\n", sqrt((sumsq[i]-sum[i]^2/NR)/NR)}
36          }' -
37 }
38 
39 function count () {
40     echo $* | wc -w
41 }
42 
43 # This tests overall improvements
44 echo "Final run: {static + dynamic} archive, +ReplayTraining and +LoadCachedCode"
45 for i in old new; do
46     nums=$(grep Booted data/time.$i.* | sed -e 's/.*in //g' -e 's/ms//g')
47     nums="$nums $(for j in data/make.$i.*; do grep Booted $j | tail -1 | sed -e 's/.*in //g' -e 's/ms//g'; done)"
48     printf "%s %8.2f ms %8.2f ms (%d samples)\n" $i $(geomean $nums) $(stdev $nums) $(count $nums)
49 done
50 
51 # This tests improvements in CDS only.
52 echo ""
53 echo "Static archive only"
54 for i in old new; do
55     nums=$(for j in data/make.$i.*; do grep Booted $j | head -2 | tail -1 | sed -e 's/.*in //g' -e 's/ms//g'; done)
56     printf "%s %8.2f ms %8.2f ms (%d samples)\n" $i $(geomean $nums) $(stdev $nums) $(count $nums)
57 done
58