Add two-step measurement method, Gantt diagrams, and update README with accurate results
This commit is contained in:
+8
-10
@@ -79,23 +79,20 @@ run_program() {
|
||||
local start=$(date +%s%N)
|
||||
|
||||
# Run program with time measurement
|
||||
result=$(/usr/bin/time -l "$@" 2>&1)
|
||||
local output=$(/usr/bin/time -l "$@" 2>&1)
|
||||
local exit_code=$?
|
||||
|
||||
local end=$(date +%s%N)
|
||||
local elapsed=$(( (end - start) / 1000000 ))
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
# Get result for verification
|
||||
# Get result for verification (first line of output)
|
||||
result=$(echo "$output" | head -n 1)
|
||||
|
||||
if [ "$i" -gt 1 ]; then
|
||||
# Only count runs 2-4 for averages
|
||||
total_time=$((total_time + elapsed))
|
||||
|
||||
# Parse time output for phases (simplified)
|
||||
local real_time=$(echo "$result" | grep "real" | awk '{print $1}')
|
||||
local user_time=$(echo "$result" | grep "user" | awk '{print $3}')
|
||||
local sys_time=$(echo "$result" | grep "sys" | awk '{print $5}')
|
||||
|
||||
# Estimate phases (simplified)
|
||||
local startup=$((elapsed / 10)) # Estimate 10% startup
|
||||
local calc=$((elapsed * 8 / 10)) # Estimate 80% calculation
|
||||
@@ -105,7 +102,7 @@ run_program() {
|
||||
total_calc=$((total_calc + calc))
|
||||
total_io=$((total_io + io))
|
||||
|
||||
if verify "$(echo "$result" | head -n 1)" "$DECIMALS"; then
|
||||
if verify "$result" "$DECIMALS"; then
|
||||
((success_count++))
|
||||
fi
|
||||
fi
|
||||
@@ -165,13 +162,14 @@ run_program Swift swift/bin/print_hej "$DECIMALS"
|
||||
run_program TypeScript typescript/bin/print_hej "$DECIMALS"
|
||||
run_program Zig zig/bin/print_hej "$DECIMALS"
|
||||
|
||||
# Sort results by time
|
||||
# Sort results by time (numerically)
|
||||
echo ""
|
||||
echo "=== RESULTAT (sorterat efter tid) ==="
|
||||
printf "%-12s %8s %8s %8s %8s\n" "Språk" "Total" "Startup" "Calc" "I/O"
|
||||
echo "------------------------------------------------"
|
||||
|
||||
for result in $(printf '%s\n' "${results[@]}" | sort -n); do
|
||||
# Sort numerically by time
|
||||
printf '%s\n' "${results[@]}" | sort -n -k1 | while read result; do
|
||||
time=$(echo "$result" | awk '{print $1}')
|
||||
name=$(echo "$result" | awk '{print $2}')
|
||||
status=$(echo "$result" | awk '{print $3}')
|
||||
|
||||
Reference in New Issue
Block a user