25 using namespace folly;
29 constexpr
int kMaxIds = 64 << 10;
30 constexpr
int kMaxTerms = 64 << 10;
39 for (
int i = 0;
i < kMaxIds;
i++) {
46 std::uniform_int_distribution<size_t> term_len(1, 10);
47 std::uniform_int_distribution<uint16_t> term_char(0x20, 0x7f);
48 for (
int i = 0;
i < kMaxTerms;
i++) {
50 int len = term_len(rng);
52 for (
int j = 0; j < len; j++) {
53 term.append(1, (
char)term_char(rng));
59 void fingerprintIds(
int num_iterations,
int num_ids) {
60 for (
int iter = 0; iter < num_iterations; iter++) {
62 for (
int i = 0;
i < num_ids;
i++) {
74 void fingerprintTerms(
int num_iterations,
int num_terms) {
75 for (
int iter = 0; iter < num_iterations; iter++) {
77 for (
int i = 0;
i < num_terms;
i++) {
88 void fastFingerprintIds64(
int num_iterations,
int num_ids) {
89 fingerprintIds<Fingerprint<64>>(num_iterations, num_ids);
92 void slowFingerprintIds64(
int num_iterations,
int num_ids) {
93 fingerprintIds<SlowFingerprint<64>>(num_iterations, num_ids);
96 void fastFingerprintIds96(
int num_iterations,
int num_ids) {
97 fingerprintIds<Fingerprint<96>>(num_iterations, num_ids);
100 void fastFingerprintIds128(
int num_iterations,
int num_ids) {
101 fingerprintIds<Fingerprint<128>>(num_iterations, num_ids);
104 void fastFingerprintTerms64(
int num_iterations,
int num_ids) {
105 fingerprintTerms<Fingerprint<64>>(num_iterations, num_ids);
108 void slowFingerprintTerms64(
int num_iterations,
int num_ids) {
109 fingerprintTerms<SlowFingerprint<64>>(num_iterations, num_ids);
112 void fastFingerprintTerms96(
int num_iterations,
int num_ids) {
113 fingerprintTerms<Fingerprint<96>>(num_iterations, num_ids);
116 void fastFingerprintTerms128(
int num_iterations,
int num_ids) {
117 fingerprintTerms<Fingerprint<128>>(num_iterations, num_ids);
127 gflags::ParseCommandLineFlags(&argc, &argv,
true);
128 #define BM(name, min, max) \ 129 for (size_t i = min; i <= max; i *= 2) { \ 131 __FILE__, sformat("{}_{}", #name, i).c_str(), [=](int iters) { \ 136 BM(fastFingerprintIds64, 1, kMaxIds)
137 BM(slowFingerprintIds64, 1, kMaxIds)
138 BM(fastFingerprintIds96, 1, kMaxIds)
139 BM(fastFingerprintIds128, 1, kMaxIds)
140 BM(fastFingerprintTerms64, 1, kMaxTerms)
141 BM(slowFingerprintTerms64, 1, kMaxTerms)
142 BM(fastFingerprintTerms96, 1, kMaxTerms)
143 BM(fastFingerprintTerms128, 1, kMaxTerms)
—— Concurrent Priority Queue Implementation ——
#define BM(name, min, max)
int main(int argc, char **argv)