Skip to content

Commit ef733e9

Browse files
committed
in-process-benching: Add timestamp and RAM to results CSV
1 parent baba47a commit ef733e9

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ The new run script is named [run-benchmark.sh](run-benchmark.sh). Let's say we r
107107
The default run time is `10000` ms. `-u` sets the user name (preferably your GitHub handle). The output was this:
108108

109109
```csv
110-
benchmark,commit_sha,is_checked,user,model,os,arch,language,run_ms,mean_ms,std-dev-ms,min_ms,max_ms,times
111-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,Babashka,10000,23427.881083,0.0,23427.881083,23427.881083,1
112-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,C,10000,31.807073,0.445006,30.904000,34.647000,315
113-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,Clojure,10000,56.76691828813559,0.5267686832135136,55.877417,58.812042,177
114-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,Clojure Native,10000,60.57034990963855,1.0826489831713852,59.068291,64.627208,166
115-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,Java,10000,54.729889,1.487086,51.871208,60.350333,183
116-
levenshtein,ed184a0,true,PEZ,Apple M4 Max,darwin24,arm64,Java Native,10000,62.124475,3.009835,54.422417,69.038625,161
110+
benchmark,timestamp,commit_sha,is_checked,user,model,ram,os,arch,language,run_ms,mean_ms,std-dev-ms,min_ms,max_ms,runs
111+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,Babashka,10000,23376.012916,0.0,23376.012916,23376.012916,1
112+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,C,10000,31.874277,0.448673,31.286000,35.599000,314
113+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,Clojure,10000,57.27048066857143,2.210445845051782,55.554958,75.566792,175
114+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,Clojure Native,10000,59.95592388622754,0.8493245545620596,58.963833,62.897834,167
115+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,Java,10000,55.194704,1.624322,52.463125,63.390833,182
116+
levenshtein,2025-01-18T23:32:41Z,8e63938,true,PEZ,Apple M4 Max,64GB,darwin24,arm64,Java Native,10000,60.704966,6.579482,51.807750,96.343541,165
117117
```
118118

119-
It's a CSV file you can open in something Excel-ish or consume with your favorite language.
119+
It's a CSV file you can open in something Excel-ish, or consume with your favorite programming language.
120120

121121
![Example Result CSV in Numbers.app](docs/example-results-csv.png)
122122

docs/example-results-csv.png

5.79 KB
Loading

run-benchmark.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,36 @@ if [ -n "${input_value}" ]; then
4141
fi
4242

4343
commit_sha=$(git rev-parse --short HEAD)
44+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
4445
benchmark_dir="/tmp/languages-benchmark"
4546
os=${OSTYPE//,/_}
4647
arch=$(uname -m)
4748

48-
if [[ "${os}" == "darwin"* ]]; then
49+
if [[ "${os}" == "darwin"* || "${os}" == "freebsd"* ]]; then
4950
model=$(sysctl -n machdep.cpu.brand_string)
5051
elif [[ "${os}" == "linux-gnu"* ]]; then
5152
model=$(lscpu | grep "Model name" | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
52-
elif [[ "${os}" == "freebsd"* ]]; then
53-
model=$(sysctl -n machdep.cpu.brand_string)
5453
else
5554
model="Unknown"
5655
fi
5756
model=${model//,/_}
5857

58+
if [[ "${os}" == "darwin"* || "${os}" == "freebsd"* ]]; then
59+
ram=$(sysctl -n hw.memsize)
60+
ram=$((ram / 1024 / 1024 / 1024))GB
61+
elif [[ "${os}" == "linux-gnu"* ]]; then
62+
ram=$(grep MemTotal /proc/meminfo | awk '{print $2}')
63+
ram=$((ram / 1024 / 1024))GB
64+
else
65+
ram="Unknown"
66+
fi
67+
5968
mkdir -p "${benchmark_dir}"
6069
results_file_name="${benchmark}_${user}_${run_ms}_${commit_sha}${only_langs_slug}.csv"
6170
results_file="${benchmark_dir}/${results_file_name}"
6271
# Data header, must match what is printed from `run`
6372
if [ "${check_only}" = false ]; then
64-
echo "benchmark,commit_sha,is_checked,user,model,os,arch,language,run_ms,mean_ms,std-dev-ms,min_ms,max_ms,times" > "${results_file}"
73+
echo "benchmark,timestamp,commit_sha,is_checked,user,model,ram,os,arch,language,run_ms,mean_ms,std-dev-ms,min_ms,max_ms,runs" > "${results_file}"
6574
echo "Running ${benchmark} benchmark..."
6675
echo "Results will be written to: ${results_file}"
6776
else
@@ -129,7 +138,7 @@ function run {
129138
local program_output=$(eval "${command_line}")
130139
result=$(echo "${program_output}" | awk -F ',' '{print $1","$2","$3","$4","$5}')
131140
fi
132-
echo "${benchmark},${commit_sha},${is_checked},${user},${model},${os},${arch},${language_name},${run_ms},${result}" | tee -a "${results_file}"
141+
echo "${benchmark},${timestamp},${commit_sha},${is_checked},${user},${model},${ram},${os},${arch},${language_name},${run_ms},${result}" | tee -a "${results_file}"
133142
fi
134143
else
135144
echo "No executable or script found for ${language_name}. Skipping."

0 commit comments

Comments
 (0)