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(); }
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(); }
/* * Name: main * Purpose: demonstrate the parallel between primitive variable declaration * and object construction. */ int main() { // // // Primitive types // Class types // // //declaration //default constructor int a; Thing thing1; //init. from constant //value constructor int b(1); Thing thing2(5); //constructor notation int c = 2; Thing thing3 = Thing(10); //assignment notation //init. from variable //copy constructor int d(c); Thing thing4(thing3); //constructor notation int e = d; Thing thing5 = thing4; //assignment notation //assignment //assignment int f = 0; Thing thing6; f = e; thing6 = thing5; //variable assignment f = 5; thing6 = Thing(15); //"constant" assignment }