static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
    auto in = gen(st.range(0));
    c.insert(in.begin(), in.end());
    benchmark::DoNotOptimize(&(*c.begin()));
    const auto end = in.data() + in.size();
    while (st.KeepRunning()) {
        for (auto it = in.data(); it != end; ++it) {
            benchmark::DoNotOptimize(&(*c.find(*it)));
        }
        benchmark::ClobberMemory();
    }
}
Exemplo n.º 2
0
static void bm_rank(benchmark::State& state) {
  const auto br = gen_binary_relation(/*max_size=*/1'000'000,
                                      /*max_object=*/object_id(100'000),
                                      /*max_label=*/label_id(state.range(0)));

  while (state.KeepRunning()) {
    auto const max_object = gen_object(br);
    auto const max_label = gen_label(br);

    DoNotOptimize(br.rank(max_object, max_label));
  }
}
void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
    auto in = gen(st.range(0));
    const auto end = in.end();
    while (st.KeepRunning()) {
        c.clear();
        c.rehash(16);
        for (auto it = in.begin(); it != end; ++it) {
            benchmark::DoNotOptimize(&(*c.insert(*it).first));
        }
        benchmark::ClobberMemory();
    }
}
void BM_SymplecticRungeKuttaNyströmIntegratorSolveHarmonicOscillator3D(
    benchmark::State& state) {  // NOLINT(runtime/references)
  Length q_error;
  Speed v_error;
  while (state.KeepRunning()) {
    SolveHarmonicOscillatorAndComputeError3D(state, q_error, v_error,
                                             integrator());
  }
  std::stringstream ss;
  ss << q_error << ", " << v_error;
  state.SetLabel(ss.str());
}
/*
 *	Measure the time it takes for android_lookupEventFormat_len
 */
static void BM_lookupEventFormat(benchmark::State& state) {
  prechargeEventMap();

  std::unordered_set<uint32_t>::const_iterator it = set.begin();

  while (state.KeepRunning()) {
    size_t len;
    android_lookupEventFormat_len(map, &len, (*it));
    ++it;
    if (it == set.end()) it = set.begin();
  }
}
static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) {
    RenderBenchmark bench;
    HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool };
    Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still };
    
    while (state.KeepRunning()) {
        prepare(map, { "{}" });
        frontend.render(map);
        prepare(map);
        frontend.render(map);
    }
}
Exemplo n.º 7
0
static void AUDIT_handleReply(benchmark::State& state) {
  auto reply = getMockReply(kBenchmarkMessages[0]);

  while (state.KeepRunning()) {
    auto ec = std::make_shared<AuditEventContext>();

    // Perform the parsing.
    handleAuditReply(reply, ec);
  }

  free((void*)reply.message);
}
static void DATABASE_store_large(benchmark::State& state) {
  // Serialize the example result set into a string.
  std::string content;
  auto qd = getExampleQueryData(20, 100);
  serializeQueryDataJSON(qd, content);

  while (state.KeepRunning()) {
    setDatabaseValue(kPersistentSettings, "benchmark", content);
  }
  // All benchmarks will share a single database handle.
  deleteDatabaseValue(kPersistentSettings, "benchmark");
}
Exemplo n.º 9
0
static void Base58Encode(benchmark::State& state)
{
    unsigned char buff[32] = {
        17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147,
        227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90,
        200, 24
    };
    unsigned char* b = buff;
    while (state.KeepRunning()) {
        EncodeBase58(b, b + 32);
    }
}
Exemplo n.º 10
0
static
void
literal(::benchmark::State& state) {
    root_logger_t root({});
    logger_facade<root_logger_t> logger(root);

    while (state.KeepRunning()) {
        logger.log(0, "[::] - esafronov [10/Oct/2000:13:55:36 -0700] 'GET /p**n.png HTTP/1.0' 200 2326");
    }

    state.SetItemsProcessed(state.iterations());
}
Exemplo n.º 11
0
static void Base58Encode(benchmark::State& state)
{
    static const std::array<unsigned char, 32> buff = {
        {
            17, 79, 8, 99, 150, 189, 208, 162, 22, 23, 203, 163, 36, 58, 147,
            227, 139, 2, 215, 100, 91, 38, 11, 141, 253, 40, 117, 21, 16, 90,
            200, 24
        }
    };
    while (state.KeepRunning()) {
        EncodeBase58(buff.data(), buff.data() + buff.size());
    }
}
Exemplo n.º 12
0
static void bm_nth_element_obj_maj(benchmark::State& state) {
  const auto br = gen_binary_relation(/*max_size=*/1'000'000,
                                      /*max_object=*/object_id(100'000),
                                      /*max_label=*/label_id(state.range(0)));

  while (state.KeepRunning()) {
    auto obj_start = gen_object(br);
    auto lab_range = gen_label_range(br);

    DoNotOptimize(br.nth_element(obj_start, lab_range.first, lab_range.second,
                                 42, brwt::obj_major));
  }
}
Exemplo n.º 13
0
static void PrevectorResize(benchmark::State& state)
{
    while (state.KeepRunning()) {
        prevector<28, T> t0;
        prevector<28, T> t1;
        for (auto x = 0; x < 1000; ++x) {
            t0.resize(28);
            t0.resize(0);
            t1.resize(29);
            t1.resize(0);
        }
    }
}
Exemplo n.º 14
0
static void Parse_Filter(benchmark::State& state) {
    while (state.KeepRunning()) {
        parse(R"FILTER(["==", "foo", "bar"])FILTER");
    }
}

static void Parse_EvaluateFilter(benchmark::State& state) {
    const style::Filter filter = parse(R"FILTER(["==", "foo", "bar"])FILTER");
    const PropertyMap properties = { { "foo", std::string("bar") } };

    while (state.KeepRunning()) {
        filter(FeatureType::Unknown, {}, [&] (const std::string& key) -> optional<Value> {
            auto it = properties.find(key);
            if (it == properties.end())
                return {};
            return it->second;
        });
    }
}

BENCHMARK(Parse_Filter);
BENCHMARK(Parse_EvaluateFilter);
Exemplo n.º 15
0
void BM_DecodePi(benchmark::State& state) {  // NOLINT(runtime/references)
  bool correct = true;
  state.PauseTiming();
  std::vector<uint8_t> input_digits = Digits();
  std::vector<uint8_t> expected_bytes = Bytes();
  state.ResumeTiming();
  while (state.KeepRunning()) {
    HexDecode(&state, &correct, input_digits, expected_bytes);
  }
  std::stringstream ss;
  ss << correct;
  state.SetLabel(ss.str());
}
Exemplo n.º 16
0
static void bm_count_distinct_labels(benchmark::State& state) {
  const auto br = gen_binary_relation(/*max_size=*/1'000'000,
                                      /*max_object=*/object_id(100'000),
                                      /*max_label=*/label_id(state.range(0)));

  while (state.KeepRunning()) {
    const auto obj_range = gen_object_range(br);
    const auto lab_range = gen_label_range(br);

    DoNotOptimize(br.count_distinct_labels(obj_range.first, obj_range.second,
                                           lab_range.first, lab_range.second));
  }
}
Exemplo n.º 17
0
static
void
literal_with_args(::benchmark::State& state) {
    root_logger_t root({});
    logger_facade<root_logger_t> logger(root);

    while (state.KeepRunning()) {
        logger.log(0, "{} - {} [{}] 'GET {} HTTP/1.0' {} {}",
            "[::]", "esafronov", "10/Oct/2000:13:55:36 -0700", "/p**n.png", 200, 2326);
    }

    state.SetItemsProcessed(state.iterations());
}
Exemplo n.º 18
0
static void BM_UNALIGNED(benchmark::State& state) {
  const int n{35};
  while (state.KeepRunning()) {
    state.PauseTiming();
    il::Array<float> v{n, 0.0f, il::align, 32, 16};
    state.ResumeTiming();
    for (il::int_t i{0}; i < v.size(); ++i) {
      v[i] = (v[i] / 5.3f) * (v[i] * v[i] + v[i]) - (12.5f / (v[i] + 0.3f)) +
             (v[i] / (14.3f / (v[i] + 1.4f))) - (v[i] / 23.0f) +
             (14.8f / (2.4f + v[i]));
    }
  }
}
Exemplo n.º 19
0
void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
    auto in = gen(st.range(0));
    const auto end = in.end();
    c.insert(in.begin(), in.end());
    benchmark::DoNotOptimize(&c);
    benchmark::DoNotOptimize(&in);
    while (st.KeepRunning()) {
        for (auto it = in.begin(); it != end; ++it) {
            benchmark::DoNotOptimize(&(*c.emplace(*it).first));
        }
        benchmark::ClobberMemory();
    }
}
Exemplo n.º 20
0
static void BM_any_5_function(benchmark::State& state) {
  Any a{0};
  int const N = state.range(0);
  while (state.KeepRunning()) {
    for (int i = 0; i != N; ++i) {
      benchmark::DoNotOptimize(a.f1());
      benchmark::DoNotOptimize(a.f2());
      benchmark::DoNotOptimize(a.f3());
      benchmark::DoNotOptimize(a.f4());
      benchmark::DoNotOptimize(a.f5());
    }
  }
}
Exemplo n.º 21
0
BENCHMARK_F(CrowdedDistance, BM_CalcCrowdingByIndices)(benchmark::State& state) {
    auto pop = population;
    while (state.KeepRunning()) {
        int numOfObjectives = population[0]->getOutput().size();
        for (int i = 0; i < numOfObjectives; ++i) {
            std::vector<int> v;
            for (unsigned int j = 0; j < population.size(); ++j) v.push_back(j);
            auto  func = [&pop,&i](const int & lhs, const int & rhs) {
                return pop[lhs]->getOutput()[i] > pop[rhs]->getOutput()[i];
            };
            std::sort(v.begin(), v.end(), func);
        }
    }
}
Exemplo n.º 22
0
[[gnu::noinline]]
void bm(benchmark::State& state, rt_dim_pair_t d){
	auto r = mitrax::random_vector< T >(d.point_count());

	while(state.KeepRunning()){
		Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > m(
			size_t(d.cols()), size_t(d.rows())
		);

		std::copy(r.begin(), r.end(), m.data());

		benchmark::DoNotOptimize(m);
	}
}
Exemplo n.º 23
0
static
void
cpp14formatter(::benchmark::State& state) {
    while (state.KeepRunning()) {
        constexpr auto formatter = blackhole::detail::formatter<
            blackhole::detail::literal_count("{} - {} [{}] 'GET {} HTTP/1.0' {} {}")
        >("{} - {} [{}] 'GET {} HTTP/1.0' {} {}");

        fmt::MemoryWriter wr;
        formatter.format(wr, "[::]", "esafronov", "10/Oct/2000:13:55:36 -0700", "/p**n.png", 200, 2326);
    }

    state.SetItemsProcessed(state.iterations());
}
Exemplo n.º 24
0
static void BM_ImageSegmentation(benchmark::State& state) {
    while (state.KeepRunning()) {
        state.PauseTiming();
        const int num_imgs = 36;
        DataSetReader dsr(std::string(ASSETS_PATH) + "/squirrel");
        auto ds = dsr.load(num_imgs);

        state.ResumeTiming();
        for (auto idx = 0; idx < num_imgs; ++idx) {
            ds->getCamera(idx).setMask(Binarize(
                ds->getCamera(idx).getImage(), cv::Scalar(0, 0, 30)));
        }
    }
}
Exemplo n.º 25
0
void BM_reverse(benchmark::State& state) {
  const auto len = static_cast<size_t>(state.range_x());
  char *t = new char[len];

  for (size_t i = 0; i < len; i++)
    t[i] = rand_r(&seed) % std::numeric_limits<char>::max();

  while (state.KeepRunning()) {
    reverse(t);
    benchmark::DoNotOptimize(t[0]);
  }

  delete[] t;
}
Exemplo n.º 26
0
BENCHMARK_DEFINE_F(threaded_t, facade)(::benchmark::State& state) {
    while (state.KeepRunning()) {
       logger.log(0, "{} - {} [{}] 'GET {} HTTP/1.0' {} {}",
           "[::]", "esafronov", "10/Oct/2000:13:55:36 -0700", "/p**n.png", 200, 2326,
           attribute_list{
               {"key#6", {42}},
               {"key#7", {3.1415}},
               {"key#8", {"value"}}
           }
       );
    }

    state.SetItemsProcessed(state.iterations());
}
Exemplo n.º 27
0
static void DeserializeBlockTest(benchmark::State& state)
{
    CDataStream stream((const char*)block_bench::block413567,
            (const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
            SER_NETWORK, PROTOCOL_VERSION);
    char a = '\0';
    stream.write(&a, 1); // Prevent compaction

    while (state.KeepRunning()) {
        CBlock block;
        stream >> block;
        assert(stream.Rewind(sizeof(block_bench::block413567)));
    }
}
Exemplo n.º 28
0
static void SQL_virtual_table_internal_long(benchmark::State& state) {
  Registry::add<BenchmarkLongTablePlugin>("table", "long_benchmark");
  PluginResponse res;
  Registry::call("table", "long_benchmark", {{"action", "columns"}}, res);

  // Attach a sample virtual table.
  auto dbc = SQLiteDBManager::get();
  attachTableInternal("long_benchmark", columnDefinition(res), dbc->db());

  while (state.KeepRunning()) {
    QueryData results;
    queryInternal("select * from long_benchmark", results, dbc->db());
  }
}
Exemplo n.º 29
0
static void BM_CeresJacobian2(benchmark::State &state) {
  while (state.KeepRunning()) {
    double jac[9];
    double vector[3] = {1.0, 2.0, 3.0};
    double bivector[3] = {1.0, 2.0, 3.0};
    double vec_ip_biv[3] = {0.0, 0.0, 0.0};
    const double *parameters[2] = {&vector[0], &bivector[0]};
    double *jacobians[2] = {jac, nullptr};

    ceres::AutoDiffCostFunction<InnerProductVectorBivectorFunctor2, 3, 3, 3>(
        new InnerProductVectorBivectorFunctor2())
        .Evaluate(parameters, &vec_ip_biv[0], jacobians);
  }
}
Exemplo n.º 30
0
static void bm_lower_bound(benchmark::State& state) {
  const auto br = gen_binary_relation(/*max_size=*/1'000'000,
                                      /*max_object=*/object_id(100'000),
                                      /*max_label=*/label_id(state.range(0)));

  while (state.KeepRunning()) {
    const auto lab_range = gen_label_range(br);
    auto start = gen_pair(br);
    start.label = clamp(start.label, lab_range.first, lab_range.second);

    DoNotOptimize(br.lower_bound(start, lab_range.first, lab_range.second,
                                 brwt::obj_major));
  }
}