Closed
Bug 596676
Opened 14 years ago
Closed 14 years ago
Make the JavaScript shell print out how long it takes to run a script
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: billm, Assigned: billm)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file, 1 obsolete file)
2.07 KB,
patch
|
dmandelin
:
review+
|
Details | Diff | Splinter Review |
For simple testing on the command line, it would be nice to print out how long it took to run a script. Doing 'time js ...' is pretty inaccurate.
Assignee | ||
Comment 1•14 years ago
|
||
This adds a command line option to the shell so that running 'js -p ...' prints out a line like the following: runtime = 19374 ns I find it useful.
Comment 2•14 years ago
|
||
Comment on attachment 475565 [details] [diff] [review] fix Nice idea. I've been putting "var t0 = new Date; print(new Date - t0)" into test files for months. >+ if (!compileOnly) { >+ int64 t1 = PRMJ_Now(); > (void)JS_ExecuteScript(cx, obj, script, NULL); >+ int64 t2 = PRMJ_Now() - t1; >+ if (printTiming) printf("runtime = %ld ns\n", t2); >+ } - PRMJ_Now returns microseconds, so you probably means "us" for the unit. But maybe it would be better to print ms with a fractional digit or two? - I think "%lld" is what does with JSInt64. - Style nit: |if (printTiming) printf("runtime = %ld ns\n", t2);| must be two lines: if (printTiming) printf("runtime = %ld ns\n", t2);
Attachment #475565 -
Flags: review?(dmandelin)
Assignee | ||
Comment 3•14 years ago
|
||
OK, now with less brain damage.
Attachment #475565 -
Attachment is obsolete: true
Attachment #475574 -
Flags: review?(dmandelin)
Comment 4•14 years ago
|
||
Comment on attachment 475574 [details] [diff] [review] updated patch Use PRMJ_USEC_PER_MSEC instead of 1000. Otherwise, r+.
Attachment #475574 -
Flags: review?(dmandelin) → review+
Assignee | ||
Comment 5•14 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/f7206e5fe349
Whiteboard: fixed-in-tracemonkey
Comment 6•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/f7206e5fe349
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•