Last Comment Bug 173345 - Performance: empty switches have strange performance characteristics
: Performance: empty switches have strange performance characteristics
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: x86 All
-- normal (vote)
: ---
Assigned To: timeless
: Jason Orendorff [:jorendorff]
Depends on:
  Show dependency treegraph
Reported: 2002-10-08 14:47 PDT by Phil Schwartau
Modified: 2011-10-07 03:49 PDT (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

timeless' testcase (2.53 KB, text/plain)
2002-10-08 14:52 PDT, Phil Schwartau
no flags Details

Description User image Phil Schwartau 2002-10-08 14:47:17 PDT
timeless is investigating the performance of the following functions in the
JS shell, xpcshell, and the JScript shell. Will attach his testcase below.

function d_void(z){switch(z){              }}
function d_nop (z){switch(z){default:      }}
function d_bk  (z){switch(z){default:break }}
function d_ret (z){switch(z){default:return}}

Here are his timing results in the three shells.
(Note the JS shell build is a few months old):

 >i:jsshell switch.js
built on Jun 28 2002 at 05:41:15
100000   min:1162  max:1272  avg:1190.7
1000000  min:11717 max:15382 avg:12972.7
100000   min:1142  max:1312  avg:1177.7
1000000  min:11587 max:11777 avg:11726.8
100000   min:1171  max:1291  avg:1197.7
1000000  min:11837 max:12008 avg:11956.2
100000   min:1181  max:1262  avg:1206.8
1000000  min:11897 max:12078 avg:12033.3

 >..\desktop\bin\xpcshell switch.js
built on Oct  3 2002 at 04:45:00
100000   min:511  max:631  avg:550.8
1000000  min:5378 max:5598 avg:5476.9
100000   min:520  max:581  avg:548.8
1000000  min:5448 max:5608 avg:5517.9
100000   min:530  max:731  avg:572.9
1000000  min:5588 max:5748 avg:5656.1
100000   min:521  max:691  avg:570.8
1000000  min:5548 max:5989 avg:5652.2

 >cscript /nologo switch.js
100000   min:821  max:901   avg:849.3
1000000  min:8292 max:20950 avg:10298.8
100000   min:811  max:1171  avg:871.2
1000000  min:8582 max:12819 avg:10421
100000   min:831  max:2444  avg:1229.8
1000000  min:8592 max:21691 avg:13011.7
100000   min:831  max:2233  avg:1232.8
1000000  min:8342 max:10686 avg:9029
Comment 1 User image Phil Schwartau 2002-10-08 14:52:21 PDT
Created attachment 102236 [details]
timeless' testcase
Comment 2 User image timeless 2002-10-08 14:58:26 PDT
Comment on attachment 102236 [details]
timeless' testcase

>    eval("function build(){print(WScript.Version + '.' + WScript.BuildVersion+)}");
whoops, somehow a + got saved in what i sent phil. it should read:
     eval("function build(){print(WScript.Version + '.' +
(this only affects cscript)
Comment 3 User image Phil Schwartau 2002-10-08 15:00:50 PDT
timeless reports the following:

Timing concerns:
* in xpcshell d_ret() seemed to be faster than d_bk()
* in jsshell d_bk() seemed to be faster than d_ret()
* in spidermonkey d_nop() is faster than d_void() (compare JScript)
* JScript's timings match what one might call logical expectations
  if one didn't spend any time thinking about implementation details
  or shortcuts.

Consistency concern:
* things get really strange when I started reading dis() and print()
Comment 4 User image Brendan Eich [:brendan] 2004-04-03 14:59:32 PST
Why is this a bug?

The timings are out of date, so if you care, the first thing to do is to
rebenchmark with warm caches filled from latest builds.


Comment 5 User image Tom Schuster [:evilpie] 2011-10-07 03:49:50 PDT
Today these are all equally fast.

Note You need to log in before you can comment on or make changes to this bug.