main() { int a, b; int length=10000000; getchar(); b=0; for(int m=0; m<length; m++) { a=clock(); thing1(a); b+=clock()-a; } cout << "\nfirst: " << b; b=0; for(int m=0; m<length; m++) { a=clock(); thing2(&a); b+=clock()-a; } cout << "\nsecond: " << b; b=0; for(int m=0; m<length; m++) { a=clock(); thing3(&a); b+=clock()-a; } cout << "\nthird: " << b; b=0; for(int m=0; m<length; m++) { a=clock(); thing4(a); b+=clock()-a; } cout << "\nfirst: " << b; b=0; for(int m=0; m<length; m++) { a=clock(); thing5(a); b+=clock()-a; } cout << "\nfirst: " << b; getchar(); }
void work() { std::unique_ptr<CopyNoSwappy> thing(new CopyNoSwappy); art::Wrapper<CopyNoSwappy> wrap(thing); std::unique_ptr<SwappyNoCopy> thing2(new SwappyNoCopy); art::Wrapper<SwappyNoCopy> wrap2(thing2); std::unique_ptr<std::vector<double> > thing3(new std::vector<double>(10,2.2)); assert(thing3->size() == 10); art::Wrapper<std::vector<double> > wrap3(thing3); assert(wrap3->size() == 10); assert(thing3.get() == 0); }
static void test_weakRefCnt(skiatest::Reporter* reporter) { SkWeakRefCnt* ref = new SkWeakRefCnt(); std::thread thing1(bounce_ref, ref); std::thread thing2(bounce_ref, ref); std::thread thing3(bounce_weak_ref, ref); std::thread thing4(bounce_weak_weak_ref, ref); thing1.join(); thing2.join(); thing3.join(); thing4.join(); REPORTER_ASSERT(reporter, ref->unique()); SkDEBUGCODE(REPORTER_ASSERT(reporter, ref->getWeakCnt() == 1)); ref->unref(); }