Commit 9ee3fc8a authored by neverlord's avatar neverlord

guard 'benchmarking'

parent 3ef2f802
......@@ -1366,19 +1366,85 @@ size_t test__tuple()
make_cow_tuple(1, 2, 3)
};
cout << "old partial function implementation for 10,000,000 matches" << endl;
constexpr size_t numInvokes = 100000000;
auto xvals = make_cow_tuple(1, 2, "3");
std::string three{"3"};
std::atomic<std::string*> p3{&three};
auto guard1 = _x1 == 1;
auto guard2 = _x1 + _x2 == 3;
auto guard3 = _x1 + _x2 == 3 && _x3 == "3";
int dummy_counter = 0;
cout << "time for for " << numInvokes << " guards(1)*" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < numInvokes; ++i)
if (guard1(1, 2, *p3))//const_cast<std::string&>(three)))
++dummy_counter;
}
cout << "time for for " << numInvokes << " guards(1)*" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < numInvokes; ++i)
if (guard1(get_ref<0>(xvals), get_ref<1>(xvals), get_ref<2>(xvals)))
++dummy_counter;
}
cout << "time for for " << numInvokes << " guards(1)" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < numInvokes; ++i)
if (util::unchecked_apply_tuple<bool>(guard1, xvals))
++dummy_counter;
}
cout << "time for for " << numInvokes << " guards(2)" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < numInvokes; ++i)
if (util::unchecked_apply_tuple<bool>(guard2, xvals))
++dummy_counter;
}
cout << "time for for " << numInvokes << " guards(3)" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < numInvokes; ++i)
if (util::unchecked_apply_tuple<bool>(guard3, xvals))
++dummy_counter;
}
cout << "time for " << numInvokes << " equal if-statements" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < (numInvokes / sizeof(testee)); ++i)
{
if (get<0>(xvals) + get<1>(xvals) == 3 && get<2>(xvals) == "3")
{
++dummy_counter;
}
}
}
cout << "old partial function implementation for " << numInvokes << " matches" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < (10000000 / sizeof(testee)); ++i)
for (size_t i = 0; i < (numInvokes / sizeof(testee)); ++i)
{
for (auto& x : testee) { old_pf(x); }
}
}
cout << "new partial function implementation for 1,000,000 matches" << endl;
cout << "new partial function implementation for " << numInvokes << " matches" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < (10000000 / sizeof(testee)); ++i)
for (size_t i = 0; i < (numInvokes / sizeof(testee)); ++i)
{
for (auto& x : testee) { new_pf.invoke(x); }
}
......@@ -1387,7 +1453,7 @@ size_t test__tuple()
cout << "old partial function with on() inside loop" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < (10000000 / sizeof(testee)); ++i)
for (size_t i = 0; i < (numInvokes / sizeof(testee)); ++i)
{
auto tmp =
(
......@@ -1403,7 +1469,7 @@ size_t test__tuple()
cout << "new partial function with on() inside loop" << endl;
{
boost::progress_timer t0;
for (size_t i = 0; i < (10000000 / sizeof(testee)); ++i)
for (size_t i = 0; i < (numInvokes / sizeof(testee)); ++i)
{
auto tmp =
(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment