Fix benchmarking functions, make it work with pthread