On Thu, 11 Aug 2005, Qingqing Zhou wrote: > It is said that the BufferBlockPointers is used to speedup the > BufferGetBlock() macro. I compared three ways of getting block pointers. > I.e., existing method (arrary method), calculating block pointer by adding > base addr and offset*blockid method (mul method) and optimizing mul method > by using bit shift (shift method). All of them calculate the block pointer > 80000 times (i.e., the BufferBlockPointers array is of size 80000), and each > take 3 rounds. > > The result is: > > SunOS/gcc 3.2 > duration round 1 of array method: 4.179 ms > duration round 2 of array method: 4.160 ms > duration round 3 of array method: 4.143 ms > duration round 1 of mul method: 3.311 ms > duration round 2 of mul method: 3.233 ms > duration round 3 of mul method: 3.233 ms > duration round 1 of shift method: 3.554 ms > duration round 2 of shift method: 3.235 ms > duration round 3 of shift method: 3.233 ms > > Linux/gcc 3.2 > duration round 1 of array method: 0.422 ms > duration round 2 of array method: 0.324 ms > duration round 3 of array method: 0.354 ms > duration round 1 of mul method: 0.271 ms > duration round 2 of mul method: 0.248 ms > duration round 3 of mul method: 0.304 ms > duration round 1 of shift method: 0.322 ms > duration round 2 of shift method: 0.239 ms > duration round 3 of shift method: 0.265 ms > > We can conclude that: > (1) mul or shift are definitely better than array method; > (2) mul and shift are comparable;
Do you have results for more recent gcc releases? Thanks, Gavin ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend