MCPcopy Create free account
hub / github.com/apple/foundationdb / threadSafetyTest

Function threadSafetyTest

fdbrpc/dsltest.actor.cpp:493–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491
492#if 0
493void threadSafetyTest() {
494 double t = timer();
495
496 int N = 10000, V = 100;
497
498 std::vector<Promise<Void>> v;
499 Event start, ready;
500 Future<Void> sender = inThread<Void>( [&] { return threadSafetySender( v, start, ready, N ); } );
501
502 for(int i=0; i<N; i++) {
503 v.clear();
504 for (int j = 0; j < V; j++)
505 v.push_back(Promise<Void>());
506 std::vector<Future<Void>> f( v.size() );
507 for(int i=0; i<v.size(); i++)
508 f[i] = v[i].getFuture();
509 std::random_shuffle( f.begin(), f.end() );
510
511 start.set();
512 int32_t count = 0;
513 for(int i=0; i<f.size(); i++)
514 threadSafetyWaiter( f[i], &count );
515 ready.block();
516
517 if (count != V)
518 std::cout << "Thread safety error: " << count << std::endl;
519 }
520
521 t = timer()-t;
522 std::cout << "Thread safety test (2t): " << (V*N/1e6/t) << "M/sec" << std::endl;
523}
524
525void threadSafetyTest2() {
526 double t = timer();

Callers 1

dsltestFunction · 0.85

Calls 11

threadSafetySenderFunction · 0.85
threadSafetyWaiterFunction · 0.85
clearMethod · 0.65
setMethod · 0.65
timerFunction · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
getFutureMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
blockMethod · 0.45

Tested by

no test coverage detected