forked from cdown/jpgfromraw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperf_probe.sh
More file actions
executable file
·67 lines (54 loc) · 2.01 KB
/
Copy pathperf_probe.sh
File metadata and controls
executable file
·67 lines (54 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
input_dir="${INPUT_DIR:-$repo_root/test_images}"
artifact_root="${ARTIFACT_ROOT:-$repo_root/perf_artifacts}"
baseline_dir="$artifact_root/baseline"
baseline_output_dir="$baseline_dir/outputs"
baseline_manifest="$baseline_dir/sha256.txt"
latest_output_dir="$artifact_root/latest/outputs"
latest_manifest="$artifact_root/latest/sha256.txt"
results_dir="$artifact_root/results"
runs="${RUNS:-10}"
warmups="${WARMUPS:-3}"
timestamp="$(date +"%Y%m%d-%H%M%S")"
hyperfine_json="$results_dir/hyperfine-$timestamp.json"
render_manifest() {
local source_dir="$1"
local manifest_path="$2"
mkdir -p "$(dirname "$manifest_path")"
: > "$manifest_path"
while IFS= read -r file; do
local rel_path="${file#$source_dir/}"
local digest
digest="$(sha256sum "$file" | awk '{print $1}')"
printf '%s %s\n' "$digest" "$rel_path" >> "$manifest_path"
done < <(find "$source_dir" -type f -name '*.jpg' | LC_ALL=C sort)
}
run_probe() {
local output_dir="$1"
rm -rf "$output_dir"
mkdir -p "$output_dir"
"$repo_root/target/release/perf_probe" "$input_dir" "$output_dir"
}
cd "$repo_root"
command -v hyperfine >/dev/null
cargo build --release --bin perf_probe
mkdir -p "$results_dir"
if [[ ! -f "$baseline_manifest" || "${UPDATE_BASELINE:-0}" == "1" ]]; then
run_probe "$baseline_output_dir"
render_manifest "$baseline_output_dir" "$baseline_manifest"
fi
hyperfine \
-N \
--warmup "$warmups" \
--runs "$runs" \
--export-json "$hyperfine_json" \
--prepare "rm -rf '$latest_output_dir'; mkdir -p '$latest_output_dir'" \
"$repo_root/target/release/perf_probe '$input_dir' '$latest_output_dir'"
run_probe "$latest_output_dir"
render_manifest "$latest_output_dir" "$latest_manifest"
diff -u "$baseline_manifest" "$latest_manifest"
printf 'Baseline manifest: %s\n' "$baseline_manifest"
printf 'Latest manifest: %s\n' "$latest_manifest"
printf 'Hyperfine results: %s\n' "$hyperfine_json"