r/ProgrammerHumor • • Jan 16 '14

[deleted by user]

[removed]

1.3k Upvotes

446 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jan 19 '14

Someone in my company send out a FizzBuzz challenge last year. In proceeding to waste a good part of an afternoon, we found several good answers. We actually found that this method was one of the slower methods, even though by calculation it should be super fast. We concluded that this form of lookup table was going to memory every time which resulted in significant lag.

The winner implemented the lookup list as a switch statement. While very similar, it ran significantly faster. My guess is the switch statement was stored in a L cache.

It was all in JS so that will have some to do with the results.

2

u/curtmack Jan 19 '14

That makes sense, but the advantage of the lookup list is that you can dynamically generate it.