Closed Bug 173345 Opened 22 years ago Closed 13 years ago

Performance: empty switches have strange performance characteristics

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: pschwartau, Assigned: timeless)

Details

Attachments

(1 file)

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
d_void()
100000   min:1162  max:1272  avg:1190.7
1000000  min:11717 max:15382 avg:12972.7
d_nop()
100000   min:1142  max:1312  avg:1177.7
1000000  min:11587 max:11777 avg:11726.8
d_bk()
100000   min:1171  max:1291  avg:1197.7
1000000  min:11837 max:12008 avg:11956.2
d_ret()
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
d_void()
100000   min:511  max:631  avg:550.8
1000000  min:5378 max:5598 avg:5476.9
d_nop()
100000   min:520  max:581  avg:548.8
1000000  min:5448 max:5608 avg:5517.9
d_bk()
100000   min:530  max:731  avg:572.9
1000000  min:5588 max:5748 avg:5656.1
d_ret()
100000   min:521  max:691  avg:570.8
1000000  min:5548 max:5989 avg:5652.2


 >cscript /nologo switch.js
d_void()
100000   min:821  max:901   avg:849.3
1000000  min:8292 max:20950 avg:10298.8
d_nop()
100000   min:811  max:1171  avg:871.2
1000000  min:8582 max:12819 avg:10421
d_bk()
100000   min:831  max:2444  avg:1229.8
1000000  min:8592 max:21691 avg:13011.7
d_ret()
100000   min:831  max:2233  avg:1232.8
1000000  min:8342 max:10686 avg:9029
Attached file timeless' testcase
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 + '.' +
WScript.BuildVersion)}");
(this only affects cscript)
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()
Summary: empty switches having strange performance characteristics → Performance: empty switches have strange performance characteristics
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.

/be

Assignee: khanson → timeless
QA Contact: pschwartau → general
Today these are all equally fast.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: