# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.

# Example:
#
# cd test/hotspot/jtreg/premain
#
# bash bench_data/do_bench.sh | tee bench_data/bench.20250930.txt
# taskset -c 1,2 bash bench_data/do_bench.sh | tee bench_data/bench.20250930-2cpu.txt

# <<<< start: capture the output of (set -x; ...)  as well
(

VERSION=$(git log -1  | head -1 | sed -e 's/commit //')

echo Raw data generated by $USER on $(date)

echo
echo HOWTO: https://github.com/openjdk/leyden/blob/$VERSION/README.md#5-benchmarking

echo
(set -x; bash -c 'cat /proc/cpuinfo | egrep "(vendor_id)|(model name)" | head -2')
(set -x; bash -c 'cat /proc/cpuinfo | egrep "(processor)" | tail -1')
(set -x; bash -c 'cat /proc/meminfo | head -1')

echo
(set -x; cat  /etc/lsb-release)

echo
(set -x; bash -c '$BLDJDK_HOME/bin/java --version')

echo
(set -x; bash -c '$MAINLINE_HOME/bin/java --version')

echo
(set -x; bash -c '$PREMAIN_HOME/bin/java --version')

echo PREMAIN_HOME: built from https://github.com/openjdk/leyden/commit/$VERSION

BENCHES=
BENCHES="$BENCHES helidon-quickstart-se"
BENCHES="$BENCHES javac_bench"
BENCHES="$BENCHES micronaut-first-app"
BENCHES="$BENCHES quarkus-getting-started"
BENCHES="$BENCHES spring-boot-getting-started"
BENCHES="$BENCHES spring-petclinic"

echo

for b in $BENCHES; do
    echo ------------------------------------------------------------
    (set -x; bash -c "cd $b; make bench")
    (set -x; bash -c "cat $b/mainline_vs_premain.md")
done

# >>>> end 
) 2>&1



