当前位置: 首页>>代码示例>>C++>>正文


C++ benchmark::State类代码示例

本文整理汇总了C++中benchmark::State的典型用法代码示例。如果您正苦于以下问题:C++ State类的具体用法?C++ State怎么用?C++ State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BM_lookupEventTag_NOT

static void BM_lookupEventTag_NOT(benchmark::State& state) {
  prechargeEventMap();

  while (set.find(notTag) != set.end()) {
    ++notTag;
    if (notTag >= USHRT_MAX) notTag = 1;
  }

  while (state.KeepRunning()) {
    size_t len;
    android_lookupEventTag_len(map, &len, notTag);
  }

  ++notTag;
  if (notTag >= USHRT_MAX) notTag = 1;
}
开发者ID:android,项目名称:platform_system_core,代码行数:16,代码来源:liblog_benchmark.cpp

示例2: BM_AdeptJacobianReverse

static void BM_AdeptJacobianReverse(benchmark::State &state) {
  while (state.KeepRunning()) {
    double jac[9];
    adept::adouble vector[3];
    adept::set_values(vector, 3, g_vector);
    adept::adouble bivector[3];
    adept::set_values(bivector, 3, g_bivector);
    g_stack.new_recording();
    adept::adouble vec_ip_biv[3] = {0.0, 0.0, 0.0};
    InnerProductVectorBivector(vector, bivector, vec_ip_biv);

    g_stack.independent(vector, 3);
    g_stack.dependent(vec_ip_biv, 3);
    g_stack.jacobian_reverse(jac);
  }
}
开发者ID:weshoke,项目名称:game,代码行数:16,代码来源:benchmark.cpp

示例3: BM_lexer

static void BM_lexer(benchmark::State& state)
{
  while (state.KeepRunning())
  {
    std::ifstream fin("benchmarks/test.sexp");
    if (!fin)
    {
      throw std::runtime_error("failed to open benchmarks/test.sexp");
    }
    else
    {
      sexp::Lexer lexer(fin);
      while(lexer.getNextToken() != sexp::Lexer::TOKEN_EOF);
    }
  }
}
开发者ID:SuperTux,项目名称:sexp-cpp,代码行数:16,代码来源:lexer.cpp

示例4: Iterate_all_files

static void Iterate_all_files(benchmark::State& state) {
  std::unique_ptr<TemporaryFile> temp_file(CreateZip());
  ZipArchiveHandle handle;
  void* iteration_cookie;
  ZipEntry data;
  ZipString name;

  while (state.KeepRunning()) {
    OpenArchive(temp_file->path, &handle);
    StartIteration(handle, &iteration_cookie);
    while (Next(iteration_cookie, &data, &name) == 0) {
    }
    EndIteration(iteration_cookie);
    CloseArchive(handle);
  }
}
开发者ID:android,项目名称:platform_system_core,代码行数:16,代码来源:zip_archive_benchmark.cpp

示例5: FindEntry_no_match

static void FindEntry_no_match(benchmark::State& state) {
  // Create a temporary zip archive.
  std::unique_ptr<TemporaryFile> temp_file(CreateZip());
  ZipArchiveHandle handle;
  ZipEntry data;

  // In order to walk through all file names in the archive, look for a name
  // that does not exist in the archive.
  std::string_view name("thisFileNameDoesNotExist");

  // Start the benchmark.
  while (state.KeepRunning()) {
    OpenArchive(temp_file->path, &handle);
    FindEntry(handle, name, &data);
    CloseArchive(handle);
  }
}
开发者ID:android,项目名称:platform_system_core,代码行数:17,代码来源:zip_archive_benchmark.cpp

示例6: DuplicateInputs

static void DuplicateInputs(benchmark::State& state)
{
    const CScript SCRIPT_PUB{CScript(OP_TRUE)};

    const CChainParams& chainparams = Params();

    CBlock block{};
    CMutableTransaction coinbaseTx{};
    CMutableTransaction naughtyTx{};

    CBlockIndex* pindexPrev = ::ChainActive().Tip();
    assert(pindexPrev != nullptr);
    block.nBits = GetNextWorkRequired(pindexPrev, &block, chainparams.GetConsensus());
    block.nNonce = 0;
    auto nHeight = pindexPrev->nHeight + 1;

    // Make a coinbase TX
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();
    coinbaseTx.vout.resize(1);
    coinbaseTx.vout[0].scriptPubKey = SCRIPT_PUB;
    coinbaseTx.vout[0].nValue = GetBlockSubsidy(nHeight, chainparams.GetConsensus());
    coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;


    naughtyTx.vout.resize(1);
    naughtyTx.vout[0].nValue = 0;
    naughtyTx.vout[0].scriptPubKey = SCRIPT_PUB;

    uint64_t n_inputs = (((MAX_BLOCK_SERIALIZED_SIZE / WITNESS_SCALE_FACTOR) - (CTransaction(coinbaseTx).GetTotalSize() + CTransaction(naughtyTx).GetTotalSize())) / 41) - 100;
    for (uint64_t x = 0; x < (n_inputs - 1); ++x) {
        naughtyTx.vin.emplace_back(GetRandHash(), 0, CScript(), 0);
    }
    naughtyTx.vin.emplace_back(naughtyTx.vin.back());

    block.vtx.push_back(MakeTransactionRef(std::move(coinbaseTx)));
    block.vtx.push_back(MakeTransactionRef(std::move(naughtyTx)));

    block.hashMerkleRoot = BlockMerkleRoot(block);

    while (state.KeepRunning()) {
        CValidationState cvstate{};
        assert(!CheckBlock(block, cvstate, chainparams.GetConsensus(), false, false));
        assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate");
    }
}
开发者ID:fanquake,项目名称:bitcoin,代码行数:46,代码来源:duplicate_inputs.cpp

示例7: BENCHMARK_F

BENCHMARK_F( Tcp4Fixture, AddEntryToTcp4Target )( benchmark::State& state ) {
  char buffer[1024];

  for(auto _ : state){
    if( stumpless_add_entry( target, entry ) <= 0 ) {
      state.SkipWithError( "could not send an entry to the tcp target" );
    }

    recv_from_handle( accepted, buffer, 1024 );
  }

  state.counters["CallsToAlloc"] = ( double ) tcp4_memory_counter.malloc_count;
  state.counters["MemoryAllocated"] = ( double ) tcp4_memory_counter.alloc_total;
  state.counters["CallsToRealloc"] = ( double ) tcp4_memory_counter.realloc_count;
  state.counters["CallsToFree"] = ( double ) tcp4_memory_counter.free_count;
  state.counters["MemoryFreed"] = ( double ) tcp4_memory_counter.free_total;
}
开发者ID:goatshriek,项目名称:stumpless,代码行数:17,代码来源:network.cpp

示例8: DATABASE_store_append

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

  size_t k = 0;
  while (state.KeepRunning()) {
    setDatabaseValue(kPersistentSettings, "key" + std::to_string(k), content);
    deleteDatabaseValue(kPersistentSettings, "key" + std::to_string(k));
    k++;
  }

  // All benchmarks will share a single database handle.
  for (size_t i = 0; i < k; ++i) {
    // deleteDatabaseValue(kPersistentSettings, "key" + std::to_string(i));
  }
}
开发者ID:PoppySeedPlehzr,项目名称:osquery,代码行数:18,代码来源:database_benchmarks.cpp

示例9: BnBExhaustion

static void BnBExhaustion(benchmark::State& state)
{
    // Setup
    std::vector<OutputGroup> utxo_pool;
    CoinSet selection;
    CAmount value_ret = 0;
    CAmount not_input_fees = 0;

    while (state.KeepRunning()) {
        // Benchmark
        CAmount target = make_hard_case(17, utxo_pool);
        SelectCoinsBnB(utxo_pool, target, 0, selection, value_ret, not_input_fees); // Should exhaust

        // Cleanup
        utxo_pool.clear();
        selection.clear();
    }
}
开发者ID:Bushstar,项目名称:bitcoin,代码行数:18,代码来源:coin_selection.cpp

示例10: BM_WindowsCriticalSection

static void BM_WindowsCriticalSection(benchmark::State& state)
{
	if (state.thread_index == 0)
	{
		InitializeCriticalSection(&CriticalSection);
	}

	while (state.KeepRunning())
	{
		EnterCriticalSection(&CriticalSection);
		LeaveCriticalSection(&CriticalSection);
	}

	if (state.thread_index == 0)
	{
		DeleteCriticalSection(&CriticalSection);
	}
}
开发者ID:bfierz,项目名称:vcl,代码行数:18,代码来源:main.cpp

示例11: bm

[[gnu::noinline]]
void bm(benchmark::State& state, D d){
	std::random_device rd;
	std::mt19937 gen(rd());
	std::uniform_int_distribution< T > dis(
		std::numeric_limits< T >::min(),
		std::numeric_limits< T >::max()
	);

	auto m = make_matrix_fn(d, [&dis, &gen](auto, auto){
		return dis(gen);
	}, maker::heap_t());

	while(state.KeepRunning()){
		auto res = sobel_x< T >(m);

		benchmark::DoNotOptimize(res);
	}
}
开发者ID:bebuch,项目名称:mitrax,代码行数:19,代码来源:mitrax_constexpr_ct_in.cpp

示例12: DeserializeAndCheckBlockTest

static void DeserializeAndCheckBlockTest(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

    const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);

    while (state.KeepRunning()) {
        CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
        stream >> block;
        assert(stream.Rewind(sizeof(block_bench::block413567)));

        CValidationState validationState;
        assert(CheckBlock(block, validationState, chainParams->GetConsensus()));
    }
}
开发者ID:The-Cypherfunks,项目名称:The-Cypherfunks,代码行数:19,代码来源:checkblock.cpp

示例13: BM_sobel

[[gnu::noinline]]
void BM_sobel(benchmark::State& state, D d){
	using value_type = InputType;

	std::random_device rd;
	std::mt19937 gen(rd());
	std::uniform_int_distribution< value_type > dis(
		std::numeric_limits< value_type >::min(),
		std::numeric_limits< value_type >::max()
	);

	auto m = make_matrix_fn(d, [&dis, &gen](auto, auto){
		return dis(gen);
	});

	while(state.KeepRunning()){
		auto res = sobel_x< ResultType >(m);
	}
}
开发者ID:bebuch,项目名称:mitrax,代码行数:19,代码来源:mitrax_constexpr.cpp

示例14: BENCH_Dart_count_multi_threaded

static void BENCH_Dart_count_multi_threaded(benchmark::State& state)
{
	while (state.KeepRunning())
	{
		uint32 nb_darts_2 = 0u;
		std::vector<uint32> nb_darts_per_thread(cgogn::nb_threads() + 2);
		for (auto& n : nb_darts_per_thread)
			n = 0u;
		nb_darts_2 = 0u;
		bench_map.parallel_foreach_dart([&nb_darts_per_thread] (cgogn::Dart, uint32 thread_index)
		{
			nb_darts_per_thread[thread_index]++;
		});
		for (uint32 n : nb_darts_per_thread)
			nb_darts_2 += n;

		cgogn_assert(nb_darts_2 == bench_map.nb_darts());
	}
}
开发者ID:etienneschmitt,项目名称:CGoGN_2,代码行数:19,代码来源:bench_multithreading.cpp

示例15: RollingBloom

static void RollingBloom(benchmark::State& state)
{
    CRollingBloomFilter filter(120000, 0.000001);
    std::vector<unsigned char> data(32);
    uint32_t count = 0;
    uint64_t match = 0;
    while (state.KeepRunning()) {
        count++;
        data[0] = count;
        data[1] = count >> 8;
        data[2] = count >> 16;
        data[3] = count >> 24;
        filter.insert(data);

        data[0] = count >> 24;
        data[1] = count >> 16;
        data[2] = count >> 8;
        data[3] = count;
        match += filter.contains(data);
    }
}
开发者ID:MentalCollatz,项目名称:DigiByteProject,代码行数:21,代码来源:rollingbloom.cpp


注:本文中的benchmark::State类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。