void print(std::ostream & metrics_out, std::ostream & length_out, std::ostream & distance_out, std::ostream & block_distance_out)
  {
    metrics_out << map.capacity() << " , ";
    metrics_out << inserts/collisions << " , ";
    metrics_out << (100.0 * inserts/collisions) / map.capacity() << " , ";
    metrics_out << inserts << " , ";
    metrics_out << (map.failed_insert() ? "true" : "false") << " , ";
    metrics_out << collisions << " , ";
    metrics_out << 1e9*(seconds/inserts) << " , ";
    metrics_out << seconds << std::endl;

    length_out << map.capacity() << " , ";
    length_out << ((100.0 *inserts/collisions) / map.capacity()) << " , ";
    length_out << collisions << " , ";
    histogram.print_length(length_out);

    distance_out << map.capacity() << " , ";
    distance_out << ((100.0 *inserts/collisions) / map.capacity()) << " , ";
    distance_out << collisions << " , ";
    histogram.print_distance(distance_out);

    block_distance_out << map.capacity() << " , ";
    block_distance_out << ((100.0 *inserts/collisions) / map.capacity()) << " , ";
    block_distance_out << collisions << " , ";
    histogram.print_block_distance(block_distance_out);
  }
  void testit( bool rehash_on_fail = true )
  {
    execution_space::fence();

    uint32_t failed_count = 0;
    do {
      failed_count = 0;
      Kokkos::parallel_reduce(inserts, *this, failed_count);

      if (rehash_on_fail && failed_count > 0u) {
        const uint32_t new_capacity = map.capacity() + ((map.capacity()*3ull)/20u) + failed_count/collisions ;
        map.rehash( new_capacity );
      }
    } while (rehash_on_fail && failed_count > 0u);

    execution_space::fence();
  }
  UnorderedMapTest( uint32_t arg_capacity, uint32_t arg_inserts, uint32_t arg_collisions)
    : capacity(arg_capacity)
    , inserts(arg_inserts)
    , collisions(arg_collisions)
    , seconds(0)
    , map(capacity)
    , histogram(map.get_histogram())
  {
    Kokkos::Timer wall_clock ;
    wall_clock.reset();

    value_type v = {};
    int loop_count = 0;
    do {
      ++loop_count;

      v = value_type();
      Kokkos::parallel_reduce(inserts, *this, v);

      if (v.failed_count > 0u) {
        const uint32_t new_capacity = map.capacity() + ((map.capacity()*3ull)/20u) + v.failed_count/collisions ;
        map.rehash( new_capacity );
      }
    } while (v.failed_count > 0u);

    seconds = wall_clock.seconds();

    switch (loop_count)
    {
    case 1u: std::cout << " \033[0;32m" << loop_count << "\033[0m "; break;
    case 2u: std::cout << " \033[1;31m" << loop_count << "\033[0m "; break;
    default: std::cout << " \033[0;31m" << loop_count << "\033[0m "; break;
    }
    std::cout << std::setprecision(2) << std::fixed << std::setw(5) << (1e9*(seconds/(inserts))) << "; " << std::flush;

    histogram.calculate();
    Device::fence();
  }
 void testit(value_type &errors)
 {
   execution_space::execution_space::fence();
   Kokkos::parallel_reduce(m_map.capacity(), *this, errors);
   execution_space::execution_space::fence();
 }