performance - Cost of assigning to array -
i have program looks this:
int i; double* = new double [2]; for(i=0;i<1000000;i++) { a[0] = 1.1231; a[0] = 1.1231; a[0] = 1.1231; .. }
the line a[0] = 1.1231; has been copied manually 10.000 times, hence command called 10.000.000.000 times. takes 8.7 seconds run. however, if run loop 10.000.000 times , copy statement manually 1.000 times (aka same number of array assignments, different layout), runtime of 3 seconds. how can be? compiling -o0. there else need disable compiler optimization? asking because optimizing program , comparing performance of different containers...
thanks!
Comments
Post a Comment