問題1.23(Profile)
と言うことで、まんま同じように取ってみた。
http://d.hatena.ne.jp/tkuro/20090828/1251471257
- オリジナル
gosh> (begin (profiler-reset) (profiler-start) (prime? 100000000003) (profiler-stop) (profiler-show)) Profiler statistics (total 45 samples, 0.45 seconds) num time/ total Name calls call(ms) samples ---------------------------------------------------+------+-------+----------- remainder 316226 0.0006 20( 44%) divides? 316226 0.0006 19( 42%) find-divisor 316227 0.0002 5( 11%) square 316227 0.0000 1( 2%) profiler-stop 1 0.0000 0( 0%) smallest-divisor 1 0.0000 0( 0%) prime? 1 0.0000 0( 0%)
- 奇数飛ばし
gosh> (begin (profiler-reset) (profiler-start) (prime?-half 100000000003) (profiler-stop) (profiler-show)) Profiler statistics (total 27 samples, 0.27 seconds) num time/ total Name calls call(ms) samples ---------------------------------------------------+------+-------+----------- remainder 158114 0.0008 12( 44%) square 158115 0.0005 8( 30%) find-divisor 158115 0.0004 7( 26%) divides? 158114 0.0000 0( 0%) next-tester 158114 0.0000 0( 0%) prime?-half 1 0.0000 0( 0%) profiler-stop 1 0.0000 0( 0%) smallest-divisor 1 0.0000 0( 0%)
ぼくのところは、両バージョンともremainder(剰余です)が支配的。それに対して、id:tkuroの方は、奇数飛ばし版の方で、
next-divisor 158114 0.0008 13( 52%)
となってる。ぼくのだと、
next-tester 158114 0.0000 0( 0%)
なので、傾向が違うなぁ。
ちなみに、オリジナル版でも、
divides? 316226 0.0006 19( 42%)
とあるが、これって、ただremainderを呼んでるだけなんすけど。。。って感じ。