refactor benchmarking code