Tiny Ruby vs. 4tH shootout

61 views
Skip to first unread message

The Beez

unread,
Jan 17, 2015, 11:43:24 AM1/17/15
to 4th-co...@googlegroups.com
Hi 4tH-ers!

I bumped into a discussion on YARV, which has made Ruby 4x times faster, so I decided to make a tiny benchmark. Just calculate FIB(34). Now, I got an ancient Ruby on my system (never use it) so, the Ruby on you machine will probably do better. Still, I was ready to get my backside whipped. Here it comes:

habe@linux-471m:~/4th.dev> time 4th cxq fib.4th
real    0m0.656s
user    0m0.632s
sys     0m0.004s
habe@linux-471m:~/4th.dev> time ruby fib.rb

real    0m7.869s
user    0m7.864s
sys     0m0.004s

Wow! Now I understand why some people find it so fast!

Led

unread,
Jan 17, 2015, 4:42:29 PM1/17/15
to 4th-co...@googlegroups.com
субота, 17-січ-2015 08:43:24 The Beez написано:
:)

But 4th calculate fib (optimized) of 40 about 16 seconds - nice result.
And Erlang calculate fib (optimized) of 100000 (100 thousand) about 1.35 (one,
point, 35) seconds:)

--
___
Led

The Beez

unread,
Jan 17, 2015, 5:24:53 PM1/17/15
to 4th-co...@googlegroups.com, led...@gmail.com


On Saturday, January 17, 2015 at 10:42:29 PM UTC+1, Led wrote:
But 4th calculate fib (optimized) of 40 about 16 seconds - nice result.
And Erlang calculate fib (optimized) of 100000 (100 thousand) about 1.35 (one,
point, 35) seconds:)

Of course, if you viciously optimize, cache code (gForth), add a JIT (Java) or otherwise add assembly, you can speed up a VM further. Even gForth beats 4tH 4-10 times. But adding functionality means adding code. 4tH is about 100K, including editor, decompiler, etc.

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages