Hi

I just noticed that math.functions round can be sped up. Compare the
version from math.functions vs the comparison version.

: round ( x -- y ) dup sgn 2 / + truncate ; inline
: round2 ( x -- y ) dup sgn 0.5 * + truncate ; inline

Testing = warm up execution of each statement, followed by 3 executions of
gc [ 10000 [ 42.3 round drop ] times ] time
gc [ 10000 [ 42.3 round2 drop ] times ] time

round results = { 0.004365148 0.004394427 0.001917139 } average = 0.0036
round2 results = { 0.001903133 0.001894752 0.001913334 } average = 0.0019

averaged results show 1.89 times speedup

on
Mac OS X 10.8.3
2 GHz Intel Core 2 Duo


Loryn Jenkins
------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to