Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added hello_baseline-lto-full-feature
Binary file not shown.
Binary file added hello_baseline-original
Binary file not shown.
Binary file added hello_comp
Binary file not shown.
Binary file added hello_eval
Binary file not shown.
Binary file added hello_lto
Binary file not shown.
Binary file added hello_minimal
Binary file not shown.
Binary file added hello_minimal_dbg
Binary file not shown.
Empty file.
Binary file added hello_mod_baseline-original
Binary file not shown.
Binary file added hello_mod_lto
Binary file not shown.
Binary file added hello_mod_minimal
Binary file not shown.
Binary file added hello_mod_partial
Binary file not shown.
Binary file added hello_partial
Binary file not shown.
50 changes: 50 additions & 0 deletions measure.sh
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions measure_output.txt
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions measure_part2.sh
Original file line number Diff line number Diff line change
@@ -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"
Binary file added pi_baseline-lto-full-feature
Binary file not shown.
Binary file added pi_baseline-original
Binary file not shown.
Binary file added pi_lto
Binary file not shown.
Binary file added pi_minimal
Binary file not shown.
Binary file added pi_partial
Binary file not shown.
1 change: 1 addition & 0 deletions test_json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(JSON.parse('{"a":1}'))
Binary file added test_json_no_json
Binary file not shown.