#include #include #include #include //#include //#include #ifdef __cplusplus extern "C" { #endif long long get_rdtsc(){ __asm{ cpuid; rdtsc; }; } #ifdef __cplusplus }; #endif #define SOME_FLOAT_VALUE 3.1415926535897932384626433832795 using namespace std; void test1(){ double volatile x, y; x = SOME_FLOAT_VALUE; y = pow(x, 2); } void test2(){ double volatile x, y; x = SOME_FLOAT_VALUE; y = x * x; } int main(){ SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); long long cycle_begin, cycle_end; cycle_begin = get_rdtsc(); for(long long i(0); i < 10000000; i++){ test1(); } cycle_end = get_rdtsc(); cout << (cycle_end - cycle_begin) << endl; cycle_begin = get_rdtsc(); for(long long i(0); i < 10000000; i++){ test2(); } cycle_end = get_rdtsc(); cout << (cycle_end - cycle_begin) << endl; return 0; } /*+class ClassTestSuite : public Test::Suite{ public: ClassTestSuite(){ TEST_ADD(ClassTestSuite::test1); TEST_ADD(ClassTestSuite::test2); } protected: virtual void setup(){} virtual void tear_down(){} private: void test1(){ double volatile x; for(int i(0); i < 10000; i++){ x = pow(SOME_FLOAT_VALUE, 2); } } void test2(){ double volatile x; for(int i(0); i < 10000; i++){ x = SOME_FLOAT_VALUE * SOME_FLOAT_VALUE; } } }; bool run_tests(){ ClassTestSuite test_suits; Test::TextOutput output(Test::TextOutput::Verbose); return test_suits.run(output, false); // Note the 'false' parameter } int main(){run_tests();return 0;}*/