lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Chris Jones once stated:
> Hey
> 
> On 16 March 2017 at 12:56, Soni L. <fakedme@gmail.com> wrote:
> 
> >
> > I do `local tinsert = table.insert` for performance.
> >
> 
> This always seems to be the argument, but is it actually valid?
> 
> I just benchmarked table.insert vs a local alias, in a loop, with one
> million iterations, and the difference was 0.01s
> 
> So I says to myself I says, Chris, that was a 4GHz i7, that's not
> necessarily fair. Repeat the test on a Raspberry Pi 2B and the difference
> is 0.16s.
> 
> This rather suggests to me that even on a very low end processor, the cost
> of individual global table lookups is so tiny that it's not worth the
> effect it has on the programmer who has to deal with the aliases. That's
> just me though :)

  This reminded me of this blog post from James Hague: http://prog21.dadgum.com/52.html

	The sieve in Atari BASIC, using timings from an article written in
	1984 by Brian Moriarty, clocks in at:

	324 seconds (or just under 5 and a half minutes)

	The Python version, running on hardware that's a generation back--no
	i7 processor or anything like that--completes in:

	3 seconds

	Now that's impressive! A straight-ahead interpreted language, one
	with garbage collection and dynamic typing and memory allocation all
	over the place, and it's still two orders of magnitude, 108 times,
	faster than what hobbyist programmers had to work with twenty-five
	years ago.

  Read the rest for the actual punchline.

  -spc (Who's first computer wasn't even a full 1 MHz in speed)