What follows is several sets of equivalent code (both in MOO and in Cold), called five seperate times with the profiling times averaged. This code was evaluated using the eval command in both LambdaMOO Core and ColdCore. The granularity provided with the ColdCore is in microseconds, which is why it is more defined. Time and tick counters were wrapped around each code segment to get the resulting numbers. More details about the execution environment is given at the end of this document.
Forced task preempting:
Cold:
MOO:var x; for x in [1 .. 100000] pause();
=> Average Seconds:for x in [1 .. 100000] suspend(0); endfor
Task preempting only when needed:
Cold:
MOO:var x; for x in [1 .. 100000] refresh();
=> Average Seconds:for x in [1 .. 100000] $command_utils:suspend_if_needed(0); endfor
Random string manipulation and i/o print:
Cold:
MOO:var x, str, line; line="this is a test of foo, do something or dont because foo will conquer all"; for x in [1 .. 1000] { for str in (line.explode()) if (str.match_regexp("^foo")) .tell("Yup"); refresh(); }
=> Average Seconds:line="this is a test of foo, do something or dont because foo will conquer all"; for x in [1 .. 1000] for str in ($string_utils:explode(line)) if (match(str, "^foo")) player:tell("Yup"); endif $command_utils:suspend_if_needed(0); endfor endfor
All tests were run on a p150+ Cyrix system running FreeBSD 2.1-STABLE. This server also runs a web server with secure sockets. Both the Cold Core and the MOO Core were running at the same time as the test. The Cold Core had five people connected at the time of the test. The MOO had one person connected at the time of the test. Both were relatively idle, other than when the tests were run. The tests were not run on both systems at the same time. Snap shots of their execution (taken with 'ps') are (MOO is the first three, Cold Core is the last one):
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND brandon 18611 0.0 37.6 6008 5324 p1 S+ 4:08PM 0:06.92 moo LambdaCore brandon 18613 0.0 0.7 380 88 p1 I+ 4:08PM 0:00.01 (MOO name-look brandon 18615 0.0 0.6 380 72 p1 I+ 4:08PM 0:00.00 (MOO name-look brandon 11534 0.0 14.2 3464 2008 p0- S Thu10PM 9:08.24 /cold/genesisThe MOO was the latest driver and core, taken from ftp.parc.xerox.com.