-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·47 lines (37 loc) · 1.27 KB
/
test.sh
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
#!/bin/bash
CURRENT_DIR=$(pwd)
# Directory containing PNG images
IMAGE_PATH="$CURRENT_DIR/test_images/image.png"
# Output directory for Resizer
RESIZER_OUTPUT_DIR="$CURRENT_DIR/test_images/resizer-output"
# Output directory for ImageMagick
IMAGEMAGICK_OUTPUT_DIR="$CURRENT_DIR/test_images/imagemagick-output"
# Ensure output directories exist
mkdir -p "$RESIZER_OUTPUT_DIR"
mkdir -p "$IMAGEMAGICK_OUTPUT_DIR"
# Path to the Resizer executable
RESIZER_PATH="./resizer"
# Number of iterations
ITERATIONS=100
# Start timing Resizer
START_TIME=$(date +%s)
for i in $(seq 1 $ITERATIONS); do
$RESIZER_PATH "$IMAGE_PATH" 1024x1024
done
END_TIME=$(date +%s)
RESIZER_DURATION=$((END_TIME - START_TIME))
echo "Resizer took $RESIZER_DURATION seconds."
# Move Resizer output to its directory
mv "${IMAGE_PATH%.*}"*_1024x1024.png "$RESIZER_OUTPUT_DIR"
# Start timing ImageMagick
START_TIME=$(date +%s)
for i in $(seq 1 $ITERATIONS); do
convert "$IMAGE_PATH" -resize 1024x1024 "$IMAGEMAGICK_OUTPUT_DIR/$(basename "${IMAGE_PATH%.*}")_$i.png"
done
END_TIME=$(date +%s)
IMAGEMAGICK_DURATION=$((END_TIME - START_TIME))
echo "ImageMagick took $IMAGEMAGICK_DURATION seconds."
# Compare times
echo "Comparison:"
echo "Resizer: $RESIZER_DURATION seconds"
echo "ImageMagick: $IMAGEMAGICK_DURATION seconds"