Skip to content

Commit

Permalink
Fix display of totals
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Sep 8, 2012
1 parent c51f59a commit 7dacbb2
Show file tree
Hide file tree
Showing 3 changed files with 313 additions and 10 deletions.
287 changes: 287 additions & 0 deletions speed/selectors.large.css
@@ -0,0 +1,287 @@
*
A
[foo]
[foo="bar"]
[foo~="bar"]
[hreflang|="en"]
[foo^="bar"]
[foo$="bar"]
[foo*="bar"]
:first-child
:root
:nth-child(n)
:nth-last-child(n)
:nth-of-type(n)
:nth-last-of-type(n)
:last-child
:first-of-type
:last-of-type
:only-child
:only-of-type
:empty
:link
:visited
:active
:hover
:focus
:lang(fr)
:target
:disabled
:enabled
:checked
::first-line
::first-letter
::before
::after
::selection
.warning
#myid
#myid
* B
* > B
* + B
* ~ B
:not(B)
:not(*)
:not([foo])
:not([foo="bar"])
:not([foo~="bar"])
:not([hreflang|="en"])
:not([foo^="bar"])
:not([foo$="bar"])
:not([foo*="bar"])
:not(:first-child)
:not(:root)
:not(:nth-child(n))
:not(:nth-last-child(n))
:not(:nth-of-type(n))
:not(:nth-last-of-type(n))
:not(:last-child)
:not(:first-of-type)
:not(:last-of-type)
:not(:only-child)
:not(:only-of-type)
:not(:empty)
:not(:link)
:not(:visited)
:not(:active)
:not(:hover)
:not(:focus)
:not(:lang(fr))
:not(:target)
:not(:disabled)
:not(:enabled)
:not(:checked)
:not(::first-line)
:not(::first-letter)
:not(::before)
:not(::after)
:not(::selection)
:not(.warning)
:not(#myid)
li,p
address
* ul, p *.t1
* ul, p *.t1
#foo p
p p[title]
address address[title="foo"] span[title="a"]
p p[class~="b"] address address[title~="foo"] span[class~="b"]
p [title~="hello world"]
p p[lang|="en"] address address[lang="fi"] span[lang|="fr"]
p p[title^="foo"]
p p[title$="bar"]
p p[title*="bar"]
li .t1 li.t2 .t3
p p.t1 p.t2
div div.teST div.te div.st div.te.st
p .t1.fail .fail.t1 .t2.fail .fail.t2
p p.t1.t2 div div.t1 address address.t5.t5
p .t1:not(.t2) :not(.t2).t1 .t2:not(.t1) :not(.t1).t2
p p:not(.t1):not(.t2) div div:not(.t1) address address:not(.t5):not(.t5)
li #t1 li#t2 li#t3 #t4
p #test#fail #fail#test #fail div #pass#pass
.warning div #Aone#Atwo, #Aone#Athree, #Atwo#Athree p #Bone#Btwo, #Bone#Bthree, #Btwo#Bthree #Cone#Ctwo, #Cone#Cthree, #Ctwo#Cthree #Done#Dtwo, #Done#Dthree, #Dtwo#Dthree
p.test a p.test *:link
p.test a p.test *:visited
p:hover a:hover
tr:hover td:hover
table
p
.a a:hover
.b a:hover .b a:link
.c :link .c :visited:hover
div:hover > p:first-child
:link, :visited :link:hover span
a:active
button:active
a:focus
p:target
p p:target
:root :target
ul > li li:lang(en-GB)
button input button:enabled input:enabled
button input button:disabled input:disabled
input, span input:checked, input:checked + span
html *:root
:root:first-child :root:last-child :root:only-child :root:nth-child(1) :root:nth-child(n) :root:nth-last-child(1) :root:nth-last-child(n) :root:first-of-type :root:last-of-type :root:only-of-type :root:nth-of-type(1) :root:nth-of-type(n) :root:nth-last-of-type(1) :root:nth-last-of-type(n) p
* html * :root p
.red ul > li:nth-child(odd) ol > li:nth-child(even) table.t1 tr:nth-child(-n+4) table.t2 td:nth-child(3n+1)
.green ul > li:nth-child(odd) ol > li:nth-child(even) table.t1 tr:nth-child(-n+4) table.t2 td:nth-child(3n+1)
.red ul > li:nth-last-child(odd) ol > li:nth-last-child(even) table.t1 tr:nth-last-child(-n+4) table.t2 td:nth-last-child(3n+1)
.green ul > li:nth-last-child(odd) ol > li:nth-last-child(even) table.t1 tr:nth-last-child(-n+4) table.t2 td:nth-last-child(3n+1)
.red p:nth-of-type(3) dl > :nth-of-type(3n+1)
.red p:nth-last-of-type(3) dl > :nth-last-of-type(3n+1)
.red .t1 td:first-child p > *:first-child
.red .t1 td:last-child p > *:last-child
.red address address:first-of-type
.red address address:last-of-type
.red p:only-child div.testText > div > p
.red .t1 :only-of-type
p:first-line
p:first-letter
p:first-letter p:before
p::first-letter
p::first-letter p::before
p::selection
p::before
p:before
p::after
p:after
.white .red div.t1 p
.white .green div.t1 p
.white .red div > p.test
.white .green div > p.test
.fail > div .control
#fail > div p
.red div.stub > p + p
.green .white div.stub > p + p
.fail + div .control
.red div.stub > p ~ p
.green div.stub > p ~ p
div.stub > * div.stub *:not(.foo)
div.stub > * div.stub *:not(#foo)
div.stub > * div.stub *:not(:link)
div.stub > * div.stub *:not(:visited)
div.stub * div.stub > * > *:not(:hover)
div.stub * div.stub > * > *:not(:active)
a:not(:focus) a
p p:not(:target)
p p:not(:target)
div.stub * div.stub *:not(:lang(fr))
button input button:not(:enabled) input:not(:enabled)
button input button:not(:disabled) input:not(:disabled)
input, span input:not(:checked), input:not(:checked) + span
p:not(:root) div *
html:not(:root), test:not(:root) p
.red ul > li:not(:nth-child(odd)) ol > li:not(:nth-child(even)) table.t1 tr:not(:nth-child(-n+4)) table.t2 td:not(:nth-child(3n+1)) table.t1 td, table.t2 td
.green ul > li:not(:nth-child(odd)) ol > li:not(:nth-child(even)) table.t1 tr:not(:nth-child(-n+4)) table.t2 td:not(:nth-child(3n+1)) table.t1 td, table.t2 td
.red ul > li:not(:nth-last-child(odd)) ol > li:not(:nth-last-child(even)) table.t1 tr:not(:nth-last-child(-n+4)) table.t2 td:not(:nth-last-child(3n+1)) table.t1 td, table.t2 td
.green ul > li:not(:nth-last-child(odd)) ol > li:not(:nth-last-child(even)) table.t1 tr:not(:nth-last-child(-n+4)) table.t2 td:not(:nth-last-child(3n+1)) table.t1 td, table.t2 td
.red p:not(:nth-of-type(3)) dl > *:not(:nth-of-type(3n+1))
.green p:not(:nth-of-type(3)) dl > *:not(:nth-of-type(3n+1))
.red p:not(:nth-last-of-type(3)) dl > *:not(:nth-last-of-type(3n+1))
.green p:not(:nth-last-of-type(3)) dl > *:not(:nth-last-of-type(3n+1))
.red .t1 td:not(:first-child) p > *:not(:first-child) table.t1 td
.green .t1 td:not(:first-child) p > *:not(:first-child) table.t1 td
.red .t1 td:not(:last-child) p > *:not(:last-child) table.t1 td
.green .t1 td:not(:last-child) p > *:not(:last-child) table.t1 td
.red address address:not(:first-of-type)
.red address address:not(:last-of-type)
.red p:not(:only-child) div.testText > div > p
.green p:not(:only-child) div.testText > div > p
.red .t1 *:not(:only-of-type)
.green .t1 *:not(:only-of-type)
p p:not(:not(p))
p blockquote > div p
p blockquote + div ~ p
p blockquote + div ~ p
p blockquote + div p
p blockquote + div p
p blockquote div > p
p blockquote ~ div + p
p blockquote ~ div + p
div :not(:enabled):not(:disabled) p
line [type~=odd] line:nth-of-type(odd) [hidden]
line [type~=odd] line:nth-of-type(odd) [hidden]
line [type~=match] line:nth-child(3n-1) [hidden]
line [type~=match] line:nth-child(3n-1) [hidden]
line [type~=match] line:nth-last-of-type(3n-1) [hidden]
line [type~=match] line:nth-last-of-type(3n-1) [hidden]
p p:empty
address:empty address .text
address:empty address .text
address:empty address .text
address address:empty .text
address address:empty .text
address address:empty .text
p p,
p .5cm
p .\5cm
p .two\ words
p .one.word
.one\.word p
p foo & address, p
foo & address, p p
foo & address, p p
p [*=test]
p [*|*=test]
::selection :selection
p p:subject
p p * p > * p + * p ~ *
:canvas :viewport :window :menu :table :select ::canvas ::viewport ::window ::menu ::table ::select
td > div td > div > span
.test > * .test > div > ::selection .test > div > :nth-child(even)::selection .test > div > :empty::selection .test > div *::selection
.test span:first-child::selection
.test span[id=b]::selection
.test #b + * + *
.test span[id=b] ~ ::selection
.test span[id=b] + ::selection
.test :not(#b):last-child::selection
.test ::selection
.test::selection
.test::selection
.test strong
.control ::selection .control > div .control > div > span .control > div > span.a .control > div > span.b .control > div > span.c .control > div > span.d .control > div > span.green .control > div > span.yellow .control > div > span.blue
textarea textarea:focus textarea::selection textarea:focus::selection
p p:hover p::selection p:hover::selection
p:first-letter p::first-letter
p::first-letter p:first-letter
p:first-line p::first-line
p::first-line p:first-line
span:before span::before
span::before span:before
span:after span::after
span::after span:after
p .fail
tests, tests * testA[|attribute] testB[|attribute="fail"] testC[|attribute~="fail"] testD[|attribute^="fail"] testE[|attribute*="fail"] testF[|attribute$="fail"] testG[|attribute|="fail"]
tests, tests * testA[|attribute] testB[|attribute="fail"] testC[|attribute~="fail"] testD[|attribute^="fail"] testE[|attribute*="fail"] testF[|attribute$="fail"] testG[|attribute|="fail"]
tests, tests * testA[*|attribute] testB[*|attribute="pass"] testC[*|attribute~="pass"] testD[*|attribute^="pass"] testE[*|attribute*="pass"] testF[*|attribute$="pass"] testG[*|attribute|="pass"]
tests, tests * testA[*|attribute] testB[*|attribute="pass"] testC[*|attribute~="pass"] testD[*|attribute^="pass"] testE[*|attribute*="pass"] testF[*|attribute$="pass"] testG[*|attribute|="pass"]
tests, tests * testA[*|attribute="pass"] testB[*|attribute="pass"]
tests, tests * testA:not([*|attribute="pass"]) testB:not([*|attribute="pass"])
p .13
p .\13
p .\31 \33
p:selection
div p::first-child
div p:not(:first-line) p:not(:after)
p span:first-line span::first-line
p p:first-line p::first-line
p p:first-letter p::first-letter
.cs .cs P .cs .a .cs .span1 span .cs .span2 .cs .span2 SPAN .cs .span2 span .ci .ci P .ci .a .ci .span1 span .ci .span2 SPAN
p foo\:bar
p ..test .foo..quux .bar.
#test #test:not(:empty)
#test1 #test1:empty #test2 #test2:empty
#test #stub ~ div div + div > div
[test] stub ~ [|attribute^=start]:not([|attribute~=mid])[|attribute*=dle][|attribute$=end] ~ t
#two:first-child #three:last-child
input, span input:indeterminate, input:indeterminate + span
input, span input:checked, input:checked + span
input, span input:not(:checked), input:not(:checked) + span
input, span input:not(:indeterminate), input:not(:indeterminate) + span
input, span input:indeterminate:checked, input:indeterminate:checked + span
input, span input:not(:indeterminate):not(:checked), input:not(:indeterminate):not(:checked) + span
p[example=publicclass]
p[example="public"]
4 changes: 4 additions & 0 deletions speed/selectors.small.css
@@ -0,0 +1,4 @@
.note
#title
div[class=example]
p:first-child
32 changes: 22 additions & 10 deletions speed/speed.js
Expand Up @@ -46,7 +46,7 @@ function( require, Benchmark, document, selectors ) {

// Benchmark options
maxTime = 0.5,
minSamples = 1,
minSamples = 3,

// Queue for benchmark suites
suites = [],
Expand Down Expand Up @@ -191,6 +191,14 @@ function( require, Benchmark, document, selectors ) {
}
}

/**
* Retrieves the position of the first column
* of the row that has just been tested
*/
function firstTestedColumn() {
return selectorIndex * (numEngines + 1) + 1;
}

/**
* Add random number to the url to stop caching
*
Expand Down Expand Up @@ -408,7 +416,7 @@ function( require, Benchmark, document, selectors ) {
* Adds the Hz result or "FAILURE" to the corresponding column for the engine
*/
function onCycle( event ) {
var i = selectorIndex * (numEngines + 1) + 1,
var i = firstTestedColumn(),
len = i + numEngines,
tableBody = get("perf-table-body"),
tds = tableBody.getElementsByTagName("td"),
Expand Down Expand Up @@ -447,7 +455,7 @@ function( require, Benchmark, document, selectors ) {
*/
function onComplete() {
var fastestHz, slowestHz, elem, attr, j, jlen, td, ret,
i = selectorIndex * (numEngines + 1) + 1,
i = firstTestedColumn(),
// Determine different elements returned
selector = selectors[ selectorIndex ],
common = getCommonReturn( selector ),
Expand Down Expand Up @@ -513,13 +521,11 @@ function( require, Benchmark, document, selectors ) {
slowest = fastest = undefined;
fastestHz = 0;
slowestHz = Infinity;
selectorIndex = selectorIndex * numEngines + 2;
for ( i in scores ) {
if ( scores[i] > fastestHz ) {
fastestHz = scores[i];
fastest = i;
}
if ( scores[i] < slowestHz ) {
} else if ( scores[i] < slowestHz ) {
slowestHz = scores[i];
slowest = i;
}
Expand All @@ -536,11 +542,17 @@ function( require, Benchmark, document, selectors ) {
get("header").appendChild( elem );

// Add totals to table
while( (elem = tds[ selectorIndex++ ]) ) {
i = firstTestedColumn();
while( (elem = tds[ i++ ]) ) {
attr = elem.getAttribute("data-engine");
if ( attr === fastest ) {
addClass( elem, "green" );
} else if ( attr === slowest ) {
addClass( elem, "red" );
}

elem.appendChild(
document.createTextNode(
scores[ elem.getAttribute("data-engine") ]
)
document.createTextNode( scores[ attr ] )
);
}
}
Expand Down

0 comments on commit 7dacbb2

Please sign in to comment.