"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > The source code is attached.
> gettimeofday(&start_t, NULL); > if (method == 0) > { > for (i = 0; i < NBuffers; i++) > k = array[i]; > } > if (method == 1) > { > for (i = 0; i < NBuffers; i++) > k = start + i*BLCKSZ; > } > if (method == 2) > { > for (i = 0; i < NBuffers; i++) > k = start + (i<<13); > } > gettimeofday(&stop_t, NULL); This is definitely going to tell us a lot more about the compiler's loop strength reduction algorithms than it is going to tell about the time to evaluate any one of these expressions in isolation. What's worse, the compiler would be quite within its rights to detect that k isn't used anywhere, and optimize the loop away completely. What I would suggest is first to fill another array with some large number of buffer numbers (randomly chosen from 1..N) and then time loops of the form for (i = 0; i < arraysize; i++) { bn = buffernumbers[i]; bufferlocs[i] = BufferGetBlock(bn); } for all three possible definitions of BufferGetBlock (where both arrays are global variables, just to be sure the compiler doesn't think it can discard the store). This should give some numbers worth trusting. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly