Skip to content

Commit

Permalink
use steady_clock and rerun benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
16BitNarwhal committed Nov 29, 2024
1 parent 495cc8d commit 7a8c9e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions pdq/cpp/bin/benchmark-mih.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ static void do_test(char* argv0, int argc, char** argv) {

facebook::pdq::index::MIH256<std::string> mih;

t1 = std::chrono::system_clock::now();
t1 = std::chrono::steady_clock::now();
for (const auto& it : haystack) {
mih.insert(it.first, it.second);
}
t2 = std::chrono::system_clock::now();
t2 = std::chrono::steady_clock::now();
elapsed_seconds_outer = t2 - t1;
seconds = elapsed_seconds_outer.count();
printf("\n");
Expand Down Expand Up @@ -172,12 +172,12 @@ static void do_test(char* argv0, int argc, char** argv) {
matches.clear();
num_matches = 0;

t1 = std::chrono::system_clock::now();
t1 = std::chrono::steady_clock::now();
for (const auto& it : needles) {
mih.bruteForceQueryAll(it.first, maxDistance, matches);
}
num_matches = matches.size();
t2 = std::chrono::system_clock::now();
t2 = std::chrono::steady_clock::now();
elapsed_seconds_outer = t2 - t1;
seconds = elapsed_seconds_outer.count();

Expand All @@ -195,12 +195,12 @@ static void do_test(char* argv0, int argc, char** argv) {
matches.clear();
num_matches = 0;

t1 = std::chrono::system_clock::now();
t1 = std::chrono::steady_clock::now();
for (const auto& it : needles) {
mih.queryAll(it.first, maxDistance, matches);
}
num_matches = matches.size();
t2 = std::chrono::system_clock::now();
t2 = std::chrono::steady_clock::now();
elapsed_seconds_outer = t2 - t1;
seconds = elapsed_seconds_outer.count();

Expand Down
24 changes: 12 additions & 12 deletions pdq/cpp/index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,45 @@ BRUTE-FORCE QUERY:
NEEDLE COUNT: 1000
HAYSTACK COUNT: 11000
TOTAL MATCH COUNT: 1000
SECONDS: 0.311571
SECONDS PER MATCH: 0.000312
SECONDS: 0.308996
SECONDS PER MATCH: 0.000309
MIH QUERY:
NEEDLE COUNT: 1000
HAYSTACK COUNT: 11000
TOTAL MATCH COUNT: 1000
SECONDS: 0.237358
SECONDS PER MATCH: 0.000237
SECONDS: 0.222451
SECONDS PER MATCH: 0.000222
$ ./benchmark-mih --distance 48
BRUTE-FORCE QUERY:
NEEDLE COUNT: 1000
HAYSTACK COUNT: 11000
TOTAL MATCH COUNT: 1000
SECONDS: 0.310662
SECONDS PER MATCH: 0.000311
SECONDS: 0.309157
SECONDS PER MATCH: 0.000309
MIH QUERY:
NEEDLE COUNT: 1000
HAYSTACK COUNT: 11000
TOTAL MATCH COUNT: 1000
SECONDS: 1.196939
SECONDS PER MATCH: 0.001197
SECONDS: 1.106560
SECONDS PER MATCH: 0.001107
$ ./benchmark-mih --haystack-size 100000 --needles-size 5000
BRUTE-FORCE QUERY:
NEEDLE COUNT: 5000
HAYSTACK COUNT: 105000
TOTAL MATCH COUNT: 5000
SECONDS: 14.809405
SECONDS PER MATCH: 0.002962
SECONDS: 14.732608
SECONDS PER MATCH: 0.002947
MIH QUERY:
NEEDLE COUNT: 5000
HAYSTACK COUNT: 105000
TOTAL MATCH COUNT: 5000
SECONDS: 5.878446
SECONDS PER MATCH: 0.001176
SECONDS: 5.529916
SECONDS PER MATCH: 0.001106
```

0 comments on commit 7a8c9e1

Please sign in to comment.