in reply to Re: Re: Re: Re: Circular buffer instead of shift/push
in thread Circular buffer instead of shift/push

As this is a very small test case, I'm not sure that it is meaningful. The idea of using an operator was to save some use of memory. In your tight loops, everything fits nicely in the L1 cache and so memory access might just be as fast.

You have a bug in your code. Instead of 'and'ing with $m you need to use $m-1.

Also, you as you used '$m' instead of '4' it might just be that Perl does not optimize it. You can either try to replace it with the number or add 'use constant'.

Your analysis is interesting though.

Cheers.

  • Comment on Re: Re: Re: Re: Re: Circular buffer instead of shift/push