Bug 43256 - Avoid timing IO in SunSpider
Summary: Avoid timing IO in SunSpider
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 43253
  Show dependency treegraph
Reported: 2010-07-30 09:24 PDT by Paul Biggar
Modified: 2011-02-11 10:25 PST (History)
1 user (show)

See Also:

Use eval() and read() instead of load() (963 bytes, patch)
2010-08-06 14:14 PDT, Paul Biggar
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Biggar 2010-07-30 09:24:14 PDT
In the standalone shell version of Sunspider, the timer is started, then load() is called on the script, and finally the timer is stopped. load() reads the file from disk, and the IO effect of this leads to a 35% increase in variance (see https://bugzilla.mozilla.org/show_bug.cgi?id=580532#c24).

The simplest solution is to read the file into a string, then start the timer, eval the string, and stop the timer. I'm told most JS engines have a read() builtin function for this (though on Firefox it is called snarf() for some reason).
Comment 1 Paul Biggar 2010-08-06 14:14:46 PDT
Created attachment 63759 [details]
Use eval() and read() instead of load()

Use read() and eval() instead of load(). Currently, only v8 supports read(), but I'm adding it to SpiderMonkey, and it is a simple change to jsc, as far as I can tell.
Comment 2 Paul Biggar 2011-02-11 10:25:53 PST
This is indirectly fixed here:

2010-11-29  Geoffrey Garen  <ggaren@apple.com>
        Improved accuracy of command-line SunSpider.

Since run() loads the file before the timer is started, there's no need for this patch.