-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnative-benchmark.sh
More file actions
executable file
·47 lines (43 loc) · 1.41 KB
/
native-benchmark.sh
File metadata and controls
executable file
·47 lines (43 loc) · 1.41 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
IMAGE_NAME="jairosvg-native"
echo "=== Building native image container ==="
docker build -f "$SCRIPT_DIR/Dockerfile.native" -t "$IMAGE_NAME" "$SCRIPT_DIR"
echo ""
echo "=== Smoke test ==="
docker run --rm "$IMAGE_NAME" --help
echo ""
echo "=== Benchmark (running inside container) ==="
docker run --rm --entrypoint /bin/bash "$IMAGE_NAME" -c '
OUT_DIR=$(mktemp -d)
printf "%-40s %10s\n" "SVG Test Case" "Time (ms)"
printf "%-40s %10s\n" "$(printf "%0.s-" $(seq 1 40))" "----------"
total_ms=0
count=0
failed=0
for svg in comparison/svg/*.svg; do
name=$(basename "$svg" .svg)
out="$OUT_DIR/${name}.png"
start=$(date +%s%N)
if /app/jairosvg "$svg" -o "$out" 2>/dev/null; then
end=$(date +%s%N)
elapsed_ms=$(( (end - start) / 1000000 ))
total_ms=$((total_ms + elapsed_ms))
count=$((count + 1))
printf "%-40s %10d\n" "$name" "$elapsed_ms"
else
end=$(date +%s%N)
elapsed_ms=$(( (end - start) / 1000000 ))
failed=$((failed + 1))
printf "%-40s %10s\n" "$name" "FAILED (${elapsed_ms}ms)"
fi
done
printf "%-40s %10s\n" "$(printf "%0.s-" $(seq 1 40))" "----------"
printf "%-40s %10d\n" "TOTAL ($count passed, $failed failed)" "$total_ms"
if [ "$count" -gt 0 ]; then
avg=$((total_ms / count))
printf "%-40s %10d\n" "AVERAGE" "$avg"
fi
rm -rf "$OUT_DIR"
'