* * * * *
The “Tonya Harding Solution” to computer benchmarks
> … we knew we had to do more to truly earn those extra credit points.
> Luckily, I had one final optimization idea:
>
> **The Tonya Harding Solution:** The benchmark program works by calling the
> optimized function, calling the naive function, and comparing the two
> times. And this gave me a truly devilish idea. I added some code to
> calc_depth_optimized that created a child process. That child process would
> wait for calc_depth_naive to start running, then send a SIGUSR1 signal to
> the benchmark process. That signal would interrupt calc_depth_naive and
> jump to a special signal handler function I'd installed:
>
> -----[ C ]-----
> void our_handler(int signal) {
> // if you can't win the race, shoot your opponent in the legs
> sleep(image_size * 4 / 10000);
> }
> -----[ END OF LINE ]-----
>
> So while we did implement a number of features that made our program
> faster, we achieved our final high score by making the naive version a
> whole lot slower. If only that 4 had been a 5 …
>
“CS 61C Performance Competition [1]”
I'll have to hand it to Carter Sande for literally beating the competition in
benchmarking.
(Although it wasn't Tonya Harding who did the attack, but Shane Stant, hired
by Harding's ex-husband Jeff Gillooly who attacked Nancy Kerrigan with a
police baton and not a gun. Harding herself claims she had nothing to do with
the attack.)
[1]
https://carter.sande.duodecima.technology/cs61c-performance/
Email author at
[email protected]