Skip to content

Instantly share code, notes, and snippets.

@Benitoite
Last active September 11, 2024 07:15
Show Gist options
  • Save Benitoite/470633de60550fb95e8776c424fe4eaf to your computer and use it in GitHub Desktop.
Save Benitoite/470633de60550fb95e8776c424fe4eaf to your computer and use it in GitHub Desktop.
RawTherapee performance timer for MacOS zsh
intel:
git clone https://github.com/Benitoite/raw-test ./raw-test ; num=$(sysctl -n hw.physicalcpu) ; sockets=1 ; total_threads=$((num * sockets)) ; name=$(system_profiler SPHardwareDataType | grep 'Processor Name:' | sed 's/Processor Name: *//' | cut -c 7-) ; mhz=$(system_profiler SPHardwareDataType | grep 'Speed:' | awk '{print $3}') ; proc=$(cat ./AboutThisBuild.txt | grep 'Processor') ; echo "\`\`\`" ; echo "================================" ; echo "Available threads = $total_threads / CPU = $name / $mhz GHz / Target = $proc" ; for (( threads = 2; threads <= total_threads; threads *= 2 )); do export OMP_NUM_THREADS=$threads ; total_time=0.0 ; n=5 ; for file in typewriter.CR2 naturalbridges.CR2 beachcabin.ARW; do time_sum=0.0 ; for (( i = 0; i < n; i++ )); do start=$(( $(date +%s%N)/1000000 )) ; rawtherapee-cli -j -s -Y -c ./raw-test/$file &> /dev/null ; finished=$(( $(date +%s%N) / 1000000 )) ; time_sum=$(( $time_sum + $finished - $start )) ; done ; avg_time=$(( $time_sum / $n )) ; total_time=$(( $total_time + $avg_time )) ; done ; echo "$(printf '%.0f\n' "$total_time") total milliseconds elapsed (average of $n runs) using OMP_NUM_THREADS = $threads" ; done ; echo "================================" ; echo "\`\`\`"
arm64:
git clone https://github.com/Benitoite/raw-test ./raw-test ; num=$(sysctl -n hw.physicalcpu) ; sockets=1 ; total_threads=$((num * sockets)) ; name=$(system_profiler SPHardwareDataType | grep 'Chip:' | sed 's/Chip: *//' | cut -c 7-) ; mhz=$(i=0 ; total=0 ; for freq in $(sudo timeout 1s powermetrics -i 1 | grep 'P-Cluster HW active frequency:' | sed 's/P-Cluster HW active frequency:*//' | cut -c2-6) ; do echo $(( total+=$freq )) > /dev/null ; i+=1 ; done ; ave=$(( $total/$i )) ; echo $ave | grep -oE '^\s*[0-9]+') ; proc=$(cat ./AboutThisBuild.txt | grep 'Processor') ; echo "\`\`\`" ; echo "================================" ; echo "Available threads = $total_threads / CPU = $name / $mhz MHz / Target = $proc" ; for (( threads = 2; threads <= total_threads; threads *= 2 )); do export OMP_NUM_THREADS=$threads ; total_time=0.0 ; n=5 ; for file in typewriter.CR2 naturalbridges.CR2 beachcabin.ARW; do time_sum=0.0 ; for (( i = 0; i < n; i++ )); do start=$(( $(date +%s%N)/1000000 )) ; rawtherapee-cli -j -s -Y -c ./raw-test/$file &> /dev/null ; finished=$(( $(date +%s%N) / 1000000 )) ; time_sum=$(( $time_sum + $finished - $start )) ; done ; avg_time=$(( $time_sum / $n )) ; total_time=$(( $total_time + $avg_time )) ; done ; echo "$(printf '%.0f\n' "$total_time") total milliseconds elapsed (average of $n runs) using OMP_NUM_THREADS = $threads" ; done ; echo "================================" ; echo "\`\`\`"
@Benitoite
Copy link
Author

================================
Available threads = 8 / CPU = 8-Core Intel Xeon E5 / 3.3 GHz / Target = Processor: nehalem-westemere
52135 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 2
31180 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 4
21606 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 8
================================

@Benitoite
Copy link
Author

Benitoite commented Sep 8, 2024

================================
Available threads = 8 / CPU =  /  GHz / Target = Processor: arm64
35587 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 2
23484 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 4
19124 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 8
================================

-DWITH_LTO="OFF"

================================
Available threads = 8 / CPU = Apple M1 /  GHz / Target = Processor: arm64
35998 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 2
22521 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 4
18509 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 8
================================

@Benitoite
Copy link
Author

+simde

LTO=ON

================================
Available threads = 8 / CPU = Apple M1 / 3075 MHz / Target = Processor: arm64
38740 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 2
25136 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 4
19227 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 8
================================

LTO=OFF

================================
Available threads = 8 / CPU = Apple M1 / 2752 MHz / Target = Processor: arm64
36620 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 2
22912 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 4
18350 total milliseconds elapsed (average of 5 runs) using OMP_NUM_THREADS = 8
================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment