I've found on my 84+ 2.55MP that mean(, when called on certain types of lists, is actually faster than sum(. Here's the timing code. Pretty standard.

Repeat checkTmr(T:End

sum( takes 26 ms, whereas mean( takes only 24 ms! Is there any reason why this might be?
While it may seem reasonable that mean is implemented by calling sum and then dividing the result by the length of the list, that's not the route that TI took. The two operators use two entirely different code paths.

The code path used by sum is general list accumulation, which also powers operators like prod. To support this generalization, though, it goes through the rather heavy general binary operation decoder/dispatcher for each iteration. This could certainly have been made general in a much leaner way, but... TI.

The code path used by mean is also generalized—for different types of means. This means it also has some unnecessary extra stuff going on, but at least the method of accumulation is fixed so there's no going through a heavy operation decoder/dispatcher.

By the way, with your sample numbers, I only found that mean was about 3% faster than sum on an 84+SE. However, on the 84+CE (in CEmu, at least), the rankings were switched: sum was about 1.5% faster than mean.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum