-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
2,977 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en-us"> | ||
<head> | ||
<title>Bean Benchmarks</title> | ||
<script src="benchmark.js"></script> | ||
<script src="../src/bean.js"></script> | ||
<script> | ||
|
||
var suite = new Benchmark.Suite | ||
|
||
suite | ||
|
||
.add( 'add( element, event, fn )' | ||
, function() { bean.add(element, 'click', function () {}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
} | ||
) | ||
|
||
.add( 'add( element, custom, fn )' | ||
, function() { bean.add(element, 'fat', function () {}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
} | ||
) | ||
|
||
.add( 'add( element, event.namespace, fn )' | ||
, function() { bean.add(element, 'click.fat', function () {}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
} | ||
) | ||
|
||
.add( 'add( element, selector, event, fn )' | ||
, function() { bean.add(element, 'a.close', 'click', function () {}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
} | ||
) | ||
|
||
.add( 'add( element, selector, event, fn )' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
, function() { bean.add(element, 'a.close', 'click', function () {}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
} | ||
) | ||
|
||
.add( 'add( {} )' | ||
, function() { bean.add(element, { | ||
'click': function () {} | ||
, 'mouseover': function () {} | ||
, 'mouseout': function () {} | ||
}) } | ||
, { 'setup': function () { var element = document.createElement('div') } | ||
, 'teardown': function () { bean.remove(element); element = null; } | ||
}) | ||
|
||
.add( 'remove()' | ||
, function() { bean.remove( element ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'click', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'remove( event )' | ||
, function() { bean.remove( element, 'click' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'click', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'remove( custom )' | ||
, function() { bean.remove( element, 'fat' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'fat', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'remove( namespace )' | ||
, function() { bean.remove( element, '.foo' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'click.foo', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'remove( event, fn )' | ||
, function() { bean.remove( element, 'click', fn ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div'), fn = function () {} | ||
while (i--) bean.add(element, 'click', function () {}) | ||
bean.add(element, 'click', fn) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'fire( event )' | ||
, function() { bean.fire( element, 'click' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'click', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'fire( custom )' | ||
, function() { bean.fire( element, 'fat' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'fat', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.add( 'fire( namespace )' | ||
, function() { bean.fire( element, '.foo' ) } | ||
, { 'setup': function () { | ||
var i = 100, element = document.createElement('div') | ||
while (i--) bean.add(element, 'click.foo', function () {}) | ||
} | ||
, 'teardown': function () { element = null; } | ||
} | ||
) | ||
|
||
.on( 'cycle' | ||
, function(e, benchmark) { | ||
if (benchmark.error) throw benchmark.error | ||
var item = document.createElement('div') | ||
item.innerHTML = benchmark.name + ': ' + (Math.round(benchmark.hz * 100) / 100) + ' ops/sec' | ||
document.body.appendChild(item) | ||
} | ||
) | ||
|
||
.on( 'complete' | ||
, function(e, benchmark) { | ||
var item = document.createElement('h3') | ||
item.innerHTML = 'benchmarking complete!' | ||
document.body.appendChild(item) | ||
} | ||
) | ||
|
||
.run({ 'async': true }); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<h1>Running Benchmark Suite</h1> | ||
</body> | ||
</html> |
Oops, something went wrong.
Just noticed this is a double benchmark of line 34 (It also made its way into the recent tweaks too).