Skip to content

Commit

Permalink
modify tests slightly to output num_iter ((3+2)-4)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed May 28, 2014
1 parent 046296a commit 602eceb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions test/recursive_wrapper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,21 @@ int main (int argc, char** argv)
test::expression result(util::recursive_wrapper<test::binary_op<test::sub> >(
test::binary_op<test::sub>(
util::recursive_wrapper<test::binary_op<test::add> >(
test::binary_op<test::add>(2,3)),10)));
test::binary_op<test::add>(2,3)),4)));

std::cerr << "TYPE OF RESULT-> " << util::apply_visitor(test::test(), result) << std::endl;

{
boost::timer::auto_cpu_timer t;
std::size_t total = 0;
int total = 0;
for (std::size_t i = 0; i < NUM_ITER; ++i)
{
total += static_cast<std::size_t>(util::apply_visitor(test::calculator(),result));
total += util::apply_visitor(test::calculator(),result);
}
std::cerr << "total=" << total << std::endl;
}

std::cerr << util::apply_visitor(test::to_string(), result) << "=" << util::apply_visitor(test::calculator(),result) << std::endl;


return EXIT_SUCCESS;
}
6 changes: 3 additions & 3 deletions test/unique_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ int main (int argc, char** argv)
const std::size_t NUM_ITER = static_cast<std::size_t>(std::stol(argv[1]));

test::expression sum(std::unique_ptr<test::binary_op<test::add>>(new test::binary_op<test::add>(2,3)));
test::expression result(std::unique_ptr<test::binary_op<test::sub>>(new test::binary_op<test::sub>(std::move(sum),10)));
test::expression result(std::unique_ptr<test::binary_op<test::sub>>(new test::binary_op<test::sub>(std::move(sum),4)));
std::cerr << "TYPE OF RESULT-> " << util::apply_visitor(test::test(),result) << std::endl;

{
boost::timer::auto_cpu_timer t;
std::size_t total = 0;
int total = 0;
for (std::size_t i = 0; i < NUM_ITER; ++i)
{
total += static_cast<std::size_t>(util::apply_visitor(test::calculator(),result));
total += util::apply_visitor(test::calculator(),result);
}
std::cerr << "total=" << total << std::endl;
}
Expand Down

0 comments on commit 602eceb

Please sign in to comment.