test.sh
This commit is contained in:
parent
0191d024e4
commit
a81950853e
4 changed files with 144 additions and 1 deletions
58
test.sh
Normal file
58
test.sh
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Funzione per calcolare la media
|
||||
calculate_mean() {
|
||||
local sum=0
|
||||
for time in "$@"; do
|
||||
sum=$(echo "$sum + $time" | bc)
|
||||
done
|
||||
echo "scale=2; $sum / $#" | bc
|
||||
}
|
||||
|
||||
# Funzione per calcolare la deviazione standard
|
||||
calculate_std_dev() {
|
||||
local mean=$1
|
||||
shift
|
||||
local sum=0
|
||||
for time in "$@"; do
|
||||
sum=$(echo "$sum + ($time - $mean)^2" | bc)
|
||||
done
|
||||
echo "scale=2; sqrt($sum / $#)" | bc
|
||||
}
|
||||
|
||||
# Esegui 100 test con Bun
|
||||
bun_times=()
|
||||
for i in {1..100}; do
|
||||
start_time=$(date +%s%3N) # Ottieni il tempo in millisecondi
|
||||
bun run only.js > /dev/null
|
||||
end_time=$(date +%s%3N)
|
||||
elapsed_time=$((end_time - start_time))
|
||||
bun_times+=($elapsed_time)
|
||||
done
|
||||
|
||||
# Calcola la media e deviazione standard per Bun
|
||||
bun_mean=$(calculate_mean "${bun_times[@]}")
|
||||
bun_std_dev=$(calculate_std_dev "$bun_mean" "${bun_times[@]}")
|
||||
|
||||
# Esegui 100 test con Node
|
||||
node_times=()
|
||||
for i in {1..100}; do
|
||||
start_time=$(date +%s%3N)
|
||||
node only.js > /dev/null
|
||||
end_time=$(date +%s%3N)
|
||||
elapsed_time=$((end_time - start_time))
|
||||
node_times+=($elapsed_time)
|
||||
done
|
||||
|
||||
# Calcola la media e deviazione standard per Node
|
||||
node_mean=$(calculate_mean "${node_times[@]}")
|
||||
node_std_dev=$(calculate_std_dev "$node_mean" "${node_times[@]}")
|
||||
|
||||
# Stampa i risultati
|
||||
echo "Bun Execution Results:"
|
||||
echo "Mean Time (ms): $bun_mean"
|
||||
echo "Standard Deviation: $bun_std_dev"
|
||||
echo ""
|
||||
echo "Node Execution Results:"
|
||||
echo "Mean Time (ms): $node_mean"
|
||||
echo "Standard Deviation: $node_std_dev"
|
||||
Loading…
Add table
Add a link
Reference in a new issue