Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #define INTERSECTIONS 100U
  2.  
  3. static void InternalIterator(benchmark::State& state)
  4. {
  5.     cs::ComponentManager manager;
  6.  
  7.     // Generate intersections
  8.     for (std::uint32_t iteration = 0U; iteration < INTERSECTIONS; iteration++)
  9.     {
  10.         manager.save(iteration, static_cast<int>(iteration));
  11.         manager.save(iteration, static_cast<float>(iteration));
  12.     }
  13.  
  14.     for (auto _ : state) {
  15.         manager.each<int, float>([](auto id, auto& i, auto& f) { /* blank */ });
  16.     }
  17. }
  18.  
  19. static void ExternalIterator(benchmark::State& state)
  20. {
  21.     cs::ComponentManager manager;
  22.  
  23.     // Generate intersections
  24.     for (std::uint32_t iteration = 0U; iteration < INTERSECTIONS; iteration++)
  25.     {
  26.         manager.save(iteration, static_cast<int>(iteration));
  27.         manager.save(iteration, static_cast<float>(iteration));
  28.     }
  29.  
  30.     for (auto _ : state) {
  31.         manager.eachWithIterator<int, float>([](auto id, auto& i, auto& f) { /* blank */ });
  32.     }
  33. }
  34.  
  35. BENCHMARK(InternalIterator);
  36. BENCHMARK(ExternalIterator);
  37. BENCHMARK_MAIN();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement