# Pass the command you want to benchmark with various numbers of CPU cores on the command line. # # Examples # # $ how_fast_do_various_numbers_of_cores_run "ffmpeg -f lavfi -i mandelbrot=s=1920x1080 -frames 50 -c:v libvpx -f null -" # # $ how_fast_do_various_numbers_of_cores_run "ffmpeg -y -f lavfi -i mandelbrot=s=1920x1080 -threads 1 -row-mt 1 -frames 50 -c:v libvpx /tmp/bench.webm" # # $ how_fast_do_various_numbers_of_cores_run "7z b" # echo "CPU cores, elapsed time in seconds" > /tmp/core_benchmark.out # Initialize report with column headings. for CPU_cores in $( seq $( nproc) ) ; do # Measure how long the command takes with different numbers of CPU cores. /usr/bin/time -o /tmp/time.out \ -f "%e" \ taskset -c 0-$(( $CPU_cores - 1 )) $@ # Actually run the command on a certain number of cores. echo $CPU_cores,$(cat /tmp/time.out) >> /tmp/core_benchmark.out # Record elapsed time for this many CPU cores. rm /tmp/time.out # Delete the file containing the elapsed time. done cat /tmp/core_benchmark.out # Report all results.