MCPcopy Create free account
hub / github.com/apache/brpc / perf_hash

Function perf_hash

test/bvar_multi_dimension_unittest.cpp:445–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443typedef size_t (*hash_fun)(const std::list<std::string>& labels_name);
444
445static uint64_t perf_hash(hash_fun fn) {
446 uint64_t cost = 0;
447 for (int i = 0; i < idc_count; i++) {
448 std::ostringstream oss_idc;
449 oss_idc << "idc" << i;
450 for (int j = 0; j < method_count; j++) {
451 std::ostringstream oss_method;
452 oss_method << "method" << j;
453 for (int k = 0; k < status_count; k++) {
454 std::ostringstream oss_status;
455 oss_status << "status" << k;
456 std::list<std::string> labels_value {oss_idc.str(), oss_method.str(), oss_status.str()};
457 butil::Timer timer(butil::Timer::STARTED);
458 size_t hash_code = fn(labels_value);
459 EXPECT_NE(0, hash_code);
460 timer.stop();
461 cost += timer.n_elapsed();
462 }
463 }
464 }
465 return cost;
466}
467
468static size_t hash_fun1(const std::list<std::string>& labels_value) {
469 size_t hash_value = 0;

Callers 1

TEST_FFunction · 0.85

Calls 2

n_elapsedMethod · 0.80
stopMethod · 0.45

Tested by

no test coverage detected