-
-
Save anonymous/9861f0dbf6bd89b02ee3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <nonius/main.h++> | |
#include <mutex> | |
#include <thread> | |
#include <condition_variable> | |
std::mutex m0; | |
std::condition_variable c0; | |
std::unique_lock<std::mutex> l0(m0); | |
NONIUS_BENCHMARK("no one waiting", []{ c0.notify_all(); }) | |
std::mutex m1; | |
std::condition_variable c1; | |
std::unique_lock<std::mutex> l1(m1); | |
std::thread waiter([]{ while(true) { c1.wait(l1); } }); // Not entirely guaranteed to be always waiting :( | |
NONIUS_BENCHMARK("someone waiting", []{ c1.notify_all(); }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment