diff --git a/hello_baseline-lto-full-feature b/hello_baseline-lto-full-feature new file mode 100755 index 000000000..84595a121 Binary files /dev/null and b/hello_baseline-lto-full-feature differ diff --git a/hello_baseline-original b/hello_baseline-original new file mode 100755 index 000000000..3d03e5725 Binary files /dev/null and b/hello_baseline-original differ diff --git a/hello_comp b/hello_comp new file mode 100755 index 000000000..4fe80496c Binary files /dev/null and b/hello_comp differ diff --git a/hello_eval b/hello_eval new file mode 100755 index 000000000..e030860a9 Binary files /dev/null and b/hello_eval differ diff --git a/hello_lto b/hello_lto new file mode 100755 index 000000000..8c905ec69 Binary files /dev/null and b/hello_lto differ diff --git a/hello_minimal b/hello_minimal new file mode 100755 index 000000000..f805d0a3c Binary files /dev/null and b/hello_minimal differ diff --git a/hello_minimal_dbg b/hello_minimal_dbg new file mode 100755 index 000000000..41fe5d3ef Binary files /dev/null and b/hello_minimal_dbg differ diff --git a/hello_mod_baseline-lto-full-feature b/hello_mod_baseline-lto-full-feature new file mode 100644 index 000000000..e69de29bb diff --git a/hello_mod_baseline-original b/hello_mod_baseline-original new file mode 100755 index 000000000..45108ea08 Binary files /dev/null and b/hello_mod_baseline-original differ diff --git a/hello_mod_lto b/hello_mod_lto new file mode 100755 index 000000000..db634d4cc Binary files /dev/null and b/hello_mod_lto differ diff --git a/hello_mod_minimal b/hello_mod_minimal new file mode 100755 index 000000000..426e2ab2c Binary files /dev/null and b/hello_mod_minimal differ diff --git a/hello_mod_partial b/hello_mod_partial new file mode 100755 index 000000000..9dc7ffdbf Binary files /dev/null and b/hello_mod_partial differ diff --git a/hello_partial b/hello_partial new file mode 100755 index 000000000..8b135d4c2 Binary files /dev/null and b/hello_partial differ diff --git a/measure.sh b/measure.sh new file mode 100644 index 000000000..fa2729fd7 --- /dev/null +++ b/measure.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Function to collect metrics for a given configuration +collect_metrics() { + local config_name=$1 + local config_lto=$2 + local qjsc_flags=$3 + + echo "Measuring configuration: $config_name (CONFIG_LTO=$config_lto, flags=$qjsc_flags)" + + make clean > /dev/null 2>&1 + make CONFIG_LTO=$config_lto > /dev/null 2>&1 + + if [ ! -f ./qjsc ]; then + echo "Failed to build qjsc for $config_name" + return + fi + + # Compile examples + ./qjsc $qjsc_flags -o "hello_${config_name}" examples/hello.js + ./qjsc $qjsc_flags -o "pi_${config_name}" examples/pi_bigint.js + + # hello_module.js requires -m. If -fno-module-loader is used, it might fail to run, but let's see if it compiles. + # Actually, if we disable module-loader, -m might still work for static modules? + # Let's check qjsc.c again. FE_MODULE_LOADER controls JS_SetModuleLoaderFunc2. + if [[ "$qjsc_flags" == *"-fno-module-loader"* ]]; then + echo "Skipping hello_module for $config_name as module-loader is disabled" + else + ./qjsc $qjsc_flags -m -o "hello_mod_${config_name}" examples/hello_module.js + fi + + # Store sizes + echo "Results for $config_name:" + ls -l "hello_${config_name}" "pi_${config_name}" 2>/dev/null | awk '{print $9 ": " $5}' + ls -l "hello_mod_${config_name}" 2>/dev/null | awk '{print $9 ": " $5}' + echo "-----------------------------------" +} + +# 1. baseline-original +collect_metrics "baseline-original" "n" "" + +# 2. baseline-lto-full-feature +collect_metrics "baseline-lto-full-feature" "y" "-flto" + +# 3. partial-runtime +collect_metrics "partial-runtime" "y" "-flto -fno-eval -fno-regexp -fno-json -fno-module-loader" + +# 4. minimal-runtime +MINIMAL_FLAGS="-flto -fno-eval -fno-regexp -fno-json -fno-proxy -fno-map -fno-typedarray -fno-promise -fno-date -fno-string-normalize -fno-module-loader -fno-weakref" +collect_metrics "minimal-runtime" "y" "$MINIMAL_FLAGS" diff --git a/measure_output.txt b/measure_output.txt new file mode 100644 index 000000000..90c818808 --- /dev/null +++ b/measure_output.txt @@ -0,0 +1,14 @@ +Measuring configuration: baseline-original (CONFIG_LTO=n, flags=) +Results for baseline-original: +hello_baseline-original: 4959848 +pi_baseline-original: 4963952 +hello_mod_baseline-original: 4960072 +----------------------------------- +Measuring configuration: baseline-lto-full-feature (CONFIG_LTO=y, flags=-flto) +Measuring configuration: baseline-lto-full-feature (CONFIG_LTO=y, flags=-flto) +lto-wrapper: warning: using serial compilation of 16 LTRANS jobs +lto-wrapper: note: see the ‘-flto’ option documentation for more information +lto-wrapper: warning: using serial compilation of 16 LTRANS jobs +lto-wrapper: note: see the ‘-flto’ option documentation for more information +lto-wrapper: warning: using serial compilation of 16 LTRANS jobs +lto-wrapper: note: see the ‘-flto’ option documentation for more information diff --git a/measure_part2.sh b/measure_part2.sh new file mode 100644 index 000000000..a26021d35 --- /dev/null +++ b/measure_part2.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Function to collect metrics for a given configuration +collect_metrics() { + local config_name=$1 + local config_lto=$2 + local qjsc_flags=$3 + + echo "Measuring configuration: $config_name (CONFIG_LTO=$config_lto, flags=$qjsc_flags)" + + make clean > /dev/null 2>&1 + make CONFIG_LTO=$config_lto > /dev/null 2>&1 + + if [ ! -f ./qjsc ]; then + echo "Failed to build qjsc for $config_name" + return + fi + + # Compile examples + ./qjsc $qjsc_flags -o "hello_${config_name}" examples/hello.js + ./qjsc $qjsc_flags -o "pi_${config_name}" examples/pi_bigint.js + + if [[ "$qjsc_flags" == *"-fno-module-loader"* ]]; then + echo "Skipping hello_module for $config_name as module-loader is disabled" + else + ./qjsc $qjsc_flags -m -o "hello_mod_${config_name}" examples/hello_module.js + fi + + # Store sizes + echo "Results for $config_name:" + ls -l "hello_${config_name}" "pi_${config_name}" 2>/dev/null | awk '{print $9 ": " $5}' + ls -l "hello_mod_${config_name}" 2>/dev/null | awk '{print $9 ": " $5}' + echo "-----------------------------------" +} + +# 2. baseline-lto-full-feature +collect_metrics "baseline-lto-full-feature" "y" "-flto" + +# 3. partial-runtime +collect_metrics "partial-runtime" "y" "-flto -fno-eval -fno-regexp -fno-json -fno-module-loader" + +# 4. minimal-runtime +MINIMAL_FLAGS="-flto -fno-eval -fno-regexp -fno-json -fno-proxy -fno-map -fno-typedarray -fno-promise -fno-date -fno-string-normalize -fno-module-loader -fno-weakref" +collect_metrics "minimal-runtime" "y" "$MINIMAL_FLAGS" diff --git a/pi_baseline-lto-full-feature b/pi_baseline-lto-full-feature new file mode 100755 index 000000000..8e58b3048 Binary files /dev/null and b/pi_baseline-lto-full-feature differ diff --git a/pi_baseline-original b/pi_baseline-original new file mode 100755 index 000000000..ec3b307c4 Binary files /dev/null and b/pi_baseline-original differ diff --git a/pi_lto b/pi_lto new file mode 100755 index 000000000..e6ef7cd82 Binary files /dev/null and b/pi_lto differ diff --git a/pi_minimal b/pi_minimal new file mode 100755 index 000000000..763e0299e Binary files /dev/null and b/pi_minimal differ diff --git a/pi_partial b/pi_partial new file mode 100755 index 000000000..117732381 Binary files /dev/null and b/pi_partial differ diff --git a/test_json.js b/test_json.js new file mode 100644 index 000000000..7803472b7 --- /dev/null +++ b/test_json.js @@ -0,0 +1 @@ +console.log(JSON.parse('{"a":1}')) diff --git a/test_json_no_json b/test_json_no_json new file mode 100755 index 000000000..6c9eee7d5 Binary files /dev/null and b/test_json_no_json differ