Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark for C++ PDQ index #1699

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

16BitNarwhal
Copy link
Contributor

Summary

Query benchmark program for pdq/cpp/index/mih.h written in C++ (located pdq/cpp/bin/benchmark-mih.cpp)
Benchmark results in pdq/cpp/index/README.md

To run:

cd pdq/cpp
make bin/benchmark-mih.cpp
./benchmark-mih

Sample results (ran on Ubuntu 24.04.1 LTS, Intel Core i7-14700KF with 20 cores, 28 threads, 64GB RAM):

$ ./benchmark-mih
BRUTE-FORCE QUERY:
NEEDLE COUNT:               1000
HAYSTACK COUNT:             11000
TOTAL MATCH COUNT:          1000
SECONDS:                    0.311571
SECONDS PER MATCH:          0.000312

MIH QUERY:
NEEDLE COUNT:               1000
HAYSTACK COUNT:             11000
TOTAL MATCH COUNT:          1000
SECONDS:                    0.237358
SECONDS PER MATCH:          0.000237

std::vector<std::pair<facebook::pdq::hashing::Hash256, std::string>> matches;
int num_matches = 0;

std::chrono::time_point<std::chrono::system_clock> t1, t2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::chrono::time_point<std::chrono::system_clock> t1, t2;
std::chrono::time_point<std::chrono::steady_clock> t1, t2;

Monotonic clocks should be used for measuring time intervals. system_clock is not necessarily monotonic, but steady_clock is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a moderator or official reviewer. I just saw this PR and want to help others avoid some common mistakes with std::chrono that have bitten me personally. Please defer to the moderator any suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants