Improved error handling in benchmark.c