I am using Google's C++ testing framework Gtest. I would like to test a function against its execution time, e.g. function foo() fails if its execution is longer than 3ms. I could not find an ASSERT statement to achieve this. Does gtest not include such a feature ?
Why not to use such simple solution?
//pseudo code
clock_t t = clock();
foo();
const double work_time = (clock() - t) / double(CLOCKS_PER_SEC);
ASSERT_TRUE(work_time <= 0.003);
Probably doesn't exist as the bug is still open: http://code.google.com/p/googletest/issues/detail?id=348
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With