((#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' '<H2>JavaScript Performance Benchmark</H2>'))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' 'This web page is a simple benchmark for JavaScript analogous to (and directly comparable with) Squeak's tinyBenchmarks.  It reports results in terms of operations/sec (simple things like addition and subscripting) and sends/sec (user-defined message to a user-defined object).<BR><BR>'))) (#'var-decls' ('opBenchmark' (#'function' (nil 'nReps') ((#'var-decls' ('size' (#'number' 8190))) (#'var-decls' ('count' nil)) (#'for-loop' (#'var-decls' ('iter' (#'number' 0))) (#'lt' (#'identifier' 'iter') (#'identifier' 'nReps')) (#'increment' (#'identifier' 'iter')) (#'block' (#'assignment' (#'identifier' 'count') (#'number' 0)) (#'assignment' (#'identifier' 'flags') (#'new' (#'call' (#'identifier' 'Array') ((#'identifier' 'size'))))) (#'for-loop' (#'var-decls' ('i' (#'number' 0))) (#'lt' (#'identifier' 'i') (#'identifier' 'size')) (#'increment' (#'identifier' 'i')) (#'assignment' (#'array-access' (#'identifier' 'flags') (#'identifier' 'i')) (#'identifier' 'true'))) (#'for-loop' (#'var-decls' ('i' (#'number' 1))) (#'leq' (#'identifier' 'i') (#'identifier' 'size')) (#'increment' (#'identifier' 'i')) (#'block' (#'if' (#'array-access' (#'identifier' 'flags') (#'minus' (#'identifier' 'i') (#'number' 1))) (#'block' (#'var-decls' ('prime' (#'plus' (#'identifier' 'i') (#'number' 1)))) (#'var-decls' ('k' (#'plus' (#'identifier' 'i') (#'identifier' 'prime')))) (#'while-loop' (#'leq' (#'identifier' 'k') (#'identifier' 'size')) (#'block' (#'assignment' (#'array-access' (#'identifier' 'flags') (#'minus' (#'identifier' 'k') (#'number' 1))) (#'identifier' 'false')) (#'assignment' (#'identifier' 'k') (#'plus' (#'identifier' 'k') (#'identifier' 'prime'))))) (#'assignment' (#'identifier' 'count') (#'plus' (#'identifier' 'count') (#'number' 1)))) nil))))) (#'return-val' (#'identifier' 'count')))))) (#'var-decls' ('msDiff' (#'function' (nil 't1' 't0') ((#'return-val' (#'minus' (#'plus' (#'times' (#'call' (#'field-access' (#'identifier' 't1') 'getSeconds') nil) (#'number' 1000)) (#'call' (#'field-access' (#'identifier' 't1') 'getMilliseconds') nil)) (#'plus' (#'times' (#'call' (#'field-access' (#'identifier' 't0') 'getSeconds') nil) (#'number' 1000)) (#'call' (#'field-access' (#'identifier' 't0') 'getMilliseconds') nil)))))))) (#'assignment' (#'field-access' (#'field-access' (#'identifier' 'Number') 'prototype') 'fib') (#'function' nil nil ((#'if' (#'lt' (#'identifier' 'this') (#'number' 2)) (#'return-val' (#'number' 1)) (#'return-val' (#'plus' (#'call' (#'field-access' (#'minus' (#'identifier' 'self') (#'number' 1)) 'fib') nil) (#'call' (#'field-access' (#'minus' (#'identifier' 'self') (#'number' 2)) 'fib') nil))))))) (#'var-decls' ('tinyBenchmarks' (#'function' nil nil ((#'var-decls' ('t0' nil) ('t1' nil) ('n1' nil) ('n2' nil) ('n3' nil) ('result' nil) ('time' nil)) (#'assignment' (#'identifier' 'n1') (#'number' 1)) (#'do-loop' (#'block' (#'assignment' (#'identifier' 'n1') (#'times' (#'identifier' 'n1') (#'number' 2))) (#'assignment' (#'identifier' 't0') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'assignment' (#'identifier' 'result') (#'call' (#'identifier' 'opBenchmark') ((#'identifier' 'n1')))) (#'assignment' (#'identifier' 't1') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'var-decls' ('time1' (#'call' (#'identifier' 'msDiff') ((#'identifier' 't1') (#'identifier' 't0'))))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'string' 'n1 = ') (#'identifier' 'n1')) (#'string' '; time = ')) (#'identifier' 'time1')) (#'string' ' milliseconds; ')) (#'call' (#'field-access' (#'divide' (#'times' (#'times' (#'identifier' 'n1') (#'number' 500000)) (#'number' 1000)) (#'identifier' 'time1')) 'toFixed') ((#'number' 0)))) (#'string' ' operations/sec.<BR>'))))) (#'lt' (#'identifier' 'time1') (#'number' 500))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' '<BR>'))) (#'assignment' (#'identifier' 'n2') (#'number' 23)) (#'do-loop' (#'block' (#'assignment' (#'identifier' 'n2') (#'plus' (#'identifier' 'n2') (#'number' 1))) (#'assignment' (#'identifier' 't0') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'assignment' (#'identifier' 'result') (#'call' (#'field-access' (#'new' (#'call' (#'identifier' 'Fibber') ((#'number' 1)))) 'fib') ((#'identifier' 'n2')))) (#'assignment' (#'identifier' 't1') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'var-decls' ('time2' (#'call' (#'identifier' 'msDiff') ((#'identifier' 't1') (#'identifier' 't0'))))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'string' 'n2 = ') (#'identifier' 'n2')) (#'string' '; time = ')) (#'identifier' 'time2')) (#'string' ' milliseconds; ')) (#'call' (#'field-access' (#'divide' (#'times' (#'identifier' 'result') (#'number' 1000)) (#'identifier' 'time2')) 'toFixed') ((#'number' 0)))) (#'string' ' sends/sec.<BR>'))))) (#'lt' (#'identifier' 'time2') (#'number' 500))) (#'assignment' (#'identifier' 'n3') (#'number' 23)) (#'do-loop' (#'block' (#'assignment' (#'identifier' 'n3') (#'plus' (#'identifier' 'n3') (#'number' 1))) (#'assignment' (#'identifier' 't0') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'assignment' (#'identifier' 'result') (#'call' (#'field-access' (#'identifier' 'n3') 'fib') nil)) (#'assignment' (#'identifier' 't1') (#'new' (#'call' (#'identifier' 'Date') nil))) (#'var-decls' ('time2' (#'call' (#'identifier' 'msDiff') ((#'identifier' 't1') (#'identifier' 't0'))))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'plus' (#'string' 'n3 = ') (#'identifier' 'n3')) (#'string' '; time = ')) (#'identifier' 'time2')) (#'string' ' milliseconds; ')) (#'call' (#'field-access' (#'divide' (#'times' (#'identifier' 'result') (#'number' 1000)) (#'identifier' 'time2')) 'toFixed') ((#'number' 0)))) (#'string' ' sends/sec.<BR>'))))) (#'lt' (#'identifier' 'time2') (#'number' 500))))))) (#'call' (#'identifier' 'tinyBenchmarks') nil) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' '<BR>Each test is run for successively longer times until it takes half a second or more, to ensure a meaningful run time on machines of different speed.  Generally the last line in the series will be your best measure.  Have fun trying this on different machines and browsers.<BR><BR>'))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' 'Occasionally you may see a result that is much worse that the others, and this is likely due either to garbage collection or to some other interruption from the operating system.  In that case, ignore the result, and rerun the tests if desired by simply reloading this page.<BR><BR>'))) (#'call' (#'field-access' (#'identifier' 'document') 'write') ((#'string' 'If you want to find out more, just view the source -- this page *is* the benchmark program.<BR><BR>  - Dan Ingalls  4/12/2006'))))
