source: doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/cpp/order.cc @ 6e6989c

ADTast-experimental
Last change on this file since 6e6989c was 6e6989c, checked in by caparsons <caparson@…>, 13 months ago

added mutex stmt benchmarking

  • Property mode set to 100644
File size: 711 bytes
Line 
1#include <cstdio>
2#include <mutex>
3#include <thread>
4#include <chrono>
5#include "../bench.h"
6#include "cppLock.hpp"
7
8cpp_test_spinlock LOCKS;
9
10bool done = false;
11uint64_t total = 0;
12void thread_main() {
13    BENCH( std::scoped_lock lock( LOCKS );, total, done )
14}
15
16int main( int argc, char * argv[] ) {
17        BENCH_START()
18    std::thread myThreads[threads];
19
20    for (int i = 0; i < threads; i++) {
21        myThreads[i] = std::thread(thread_main); // move constructed
22    }
23
24    std::this_thread::sleep_for (std::chrono::seconds(10));
25    done = true;
26   
27    for (int i = 0; i < threads; i++) {
28        myThreads[i].join();
29    }
30
31        printf( "%lu\n", total );
32}
33
34// Local Variables: //
35// tab-width: 4 //
36// End: //
Note: See TracBrowser for help on using the repository browser.