Skip to content

Commit

Permalink
prevent optimizing
Browse files Browse the repository at this point in the history
  • Loading branch information
baruxu committed Jun 6, 2024
1 parent 56f2857 commit 32f7666
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ struct TestGroup
}
};

#define RUN_BASIC_TEST_GROUP(NAME, OP1,OP2, NUM,COUNT, Min, Max) \
#define RUN_BASIC_TEST_GROUP(NAME, OP1, NUM,COUNT, Min, Max) \
{\
TestGroup g(NAME, NUM, COUNT, Min, Max);\
for (uint64_t i = 0; i < NUM; ++i)\
{\
RUN_TEST(a OP1##= b, a OP2##= b,COUNT,Min,Max)\
RUN_TEST(a OP1##= b, b OP1##= a,COUNT,Min,Max)\
}\
}

Expand Down Expand Up @@ -177,28 +177,11 @@ auto benchmark = [](){

printf(" arithmetic|[ min, max]|fixed point| hard float|\n");

RUN_BASIC_TEST_GROUP("add/sub", +, -, 0xff, count1, -100, 100);
RUN_BASIC_TEST_GROUP("add", +, 0xff, count1, -100, 100);
RUN_BASIC_TEST_GROUP("sub", -, 0xff, count1, -100, 100);

#if FIXED_64_ENABLE_INT128_ACCELERATION
RUN_BASIC_TEST_GROUP("mul/div", *, /, 0xff, count2, 0, 0.5);
RUN_BASIC_TEST_GROUP("mul/div", *, /, 0xff, count2, 0.5, 1);
RUN_BASIC_TEST_GROUP("mul/div", *, /, 0xff, count2, 1, 2);
RUN_BASIC_TEST_GROUP("mul/div", *, /, 0xff, count2, 2, 100);
#else
RUN_BASIC_TEST_GROUP("mul", *, * , 0xff, count2, -100,100);

RUN_BASIC_TEST_GROUP("mul", *, *, 0xff, count2, 0, 0.5);
RUN_BASIC_TEST_GROUP("mul", *, *, 0xff, count2, 0.5, 1);
RUN_BASIC_TEST_GROUP("mul", *, *, 0xff, count2, 1, 2);
RUN_BASIC_TEST_GROUP("mul", *, *, 0xff, count2, 2, 100);

RUN_BASIC_TEST_GROUP("div", /, / , 0xff, count2, -100, 100);

RUN_BASIC_TEST_GROUP("div", / , / , 0xff, count2, 0, 0.5);
RUN_BASIC_TEST_GROUP("div", / , / , 0xff, count2, 0.5, 1);
RUN_BASIC_TEST_GROUP("div", / , / , 0xff, count2, 1, 2);
RUN_BASIC_TEST_GROUP("div", / , / , 0xff, count2, 2, 100);
#endif
RUN_BASIC_TEST_GROUP("mul", *, 0xff, count2, -100,100);
RUN_BASIC_TEST_GROUP("div", /, 0xff, count2, -100, 100);

const uint64_t count3 = 0xffff'f;
using namespace f64;
Expand Down

0 comments on commit 32f7666

Please sign in to comment.