-
Notifications
You must be signed in to change notification settings - Fork 0
/
compare_AdobeDNGConverter_arguments.sh
executable file
·78 lines (65 loc) · 2.92 KB
/
compare_AdobeDNGConverter_arguments.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# This script runs Adobe DNG Converter CLI with a bunch of different arguments
# and compares their runtime and output file sizes
# WARNING: This script will be creating (and destroying) a .DNG folder
# This script is expecting to be ran in a folder that has a bunch of *.GPR files:
# $ ls
# GOPR0000.GPR
# GOPR0001.GPR
# compare_AdobeDNGConverter_arguments.sh
# $ ./compare_AdobeDNGConverter_arguments.sh
# Author: Matt Popovich (mattpopovich.com)
# Stop running script if any command fails
set -e
# Create a (hidden) .DNG folder to store our converted files
mkdir .DNG
# Will pass the argument given to Adobe DNG Converter
function test_flags(){
/Applications/Adobe\ DNG\ Converter.app/Contents/MacOS/Adobe\ DNG\ Converter $1 -d .DNG *.GPR
}
flags_array=(
"-c -p1 -cr7.1 -dng1.7.1" # Default values for AdobeDNGConverter 16.2.0
"-u -p1 -cr7.1 -dng1.7.1"
"-l -p1 -cr7.1 -dng1.7.1"
"-c -p1 -e -cr7.1 -dng1.7.1"
"-c -p0 -cr7.1 -dng1.7.1"
"-c -p2 -cr7.1 -dng1.7.1"
"-c -p1 -fl -cr7.1 -dng1.7.1"
"-c -p1 -lossy -cr7.1 -dng1.7.1"
"-c -p1 -mp -cr7.1 -dng1.7.1"
)
# Get default statistics
start_time=$(ruby -e 'puts Time.now.to_f') # Alternatives: https://serverfault.com/a/423642/453183
test_flags "${flags_array[0]}" > /dev/null 2>/dev/null
end_time=$(ruby -e 'puts Time.now.to_f')
default_run_time=$(echo "${end_time} - ${start_time}" | bc)
default_file_sizes=$(ls -l .DNG | awk '{sum += $5} END {print sum}')
echo "Default = ${default_file_sizes}B, ${default_run_time}s"
rm .DNG/*
# Get statistics for flags
for flags in "${flags_array[@]}"; do
# Run Adobe DNG Converter and record runtime
start_time=$(ruby -e 'puts Time.now.to_f') # https://serverfault.com/a/423642/453183
test_flags "$flags" > /dev/null 2>/dev/null # Suppress GPU Warnings
end_time=$(ruby -e 'puts Time.now.to_f')
run_time=$(echo "${end_time} - ${start_time}" | bc)
# Calculate time differences
time_difference=$(echo "${run_time} - ${default_run_time}" | bc)
percent_time_difference=$(echo "100 * ${time_difference} / ${default_run_time}" | bc)
if (( $(echo "$time_difference >= 0" | bc -l) )); then
time_difference="+${time_difference}"
percent_time_difference="+${percent_time_difference}"
fi
# Calculate file size differences
file_size=$(ls -l .DNG | awk '{sum += $5} END {print sum}')
size_difference=$(echo "${file_size} - ${default_file_sizes}" | bc)
percent_size_difference=$(echo "100 * ${size_difference} / ${default_file_sizes}" | bc)
if (( $(echo "$size_difference >= 0" | bc -l) )); then
size_difference="+${size_difference}"
percent_size_difference="+${percent_size_difference}"
fi
# Output statistics
echo "Using flags ${flags} = ${time_difference}s (${percent_time_difference}%), ${size_difference}B (${percent_size_difference}%) vs default"
rm .DNG/*
done
# Remove temporary folder
rm -r .DNG