Skip to content
Browse files

Add node-base benchmarks.

  • Loading branch information...
1 parent fe21baf commit 12c85a3312715499452035bb26c19098240f348a @msweeney msweeney committed Jan 9, 2013
View
40 src/node/tests/perf/node-attrs-benchmark.js
@@ -0,0 +1,40 @@
+YUI.add('node-attrs-benchmark', function (Y) {
+ var suite = Y.BenchmarkSuite = new Benchmark.Suite(),
+ testNode = Y.one('#test-node'),
+ testOptions = Y.one('#test-options select'),
+ bodyNode = Y.one('body');
+
+
+ suite.add('node.get("text")', function() {
+ testNode.get('text');
+ });
+
+ suite.add('node.set("text", "new text")', function() {
+ testNode.set('text', 'new text');
+ });
+
+ suite.add('node.get("children")', function() {
+ testNode.get('children');
+ });
+
+ suite.add('node.get("options")', function() {
+ testOptions.get('options');
+ });
+
+ suite.add('node.get("value")', function() {
+ testOptions.get('value');
+ });
+
+ suite.add('node.set("value", "2")', function() {
+ testOptions.set('value', "2");
+ });
+
+ suite.add('node.setAttribute("data-foo", "foo")', function() {
+ testNode.setAttribute('data-foo', 'foo');
+ });
+
+ suite.add('node.getAttribute("data-foo")', function() {
+ testNode.getAttribute('data-foo');
+ });
+
+}, '@VERSION@', {requires: ['node-base']});
View
82 src/node/tests/perf/node-attrs.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Benchmarks</title>
+</head>
+<body class="yui3-skin-sam">
+
+<p><button id="start">Start Benchmarks</button></p>
+
+<div id="log"></div>
+<div id="test-node">
+ <span>
+ <em>
+ <strong>
+ test attrs
+ </strong>
+ </em>
+ </span>
+</div>
+
+<form id="test-options" action="#">
+ <select>
+ <option>1</option>
+ <option>2</option>
+ <option>3</option>
+ <option>4</option>
+ <option>5</option>
+ </select>
+</form>
+
+<applet code="nano" archive="https://github.com/bestiejs/benchmark.js/raw/v1.0.0/nano.jar" style="display: none;"></applet>
+<script src="http://pieisgood.org/misc/benchmark/benchmark.js"></script>
+
+<script src="../../../../build/yui/yui.js"></script>
+<script>
+var Y = YUI({
+ modules: {
+ 'node-attrs-benchmark': {
+ fullpath: 'node-attrs-benchmark.js',
+ requires: ['node-base']
+ },
+
+ 'test-console': {
+ fullpath : '../../../common/tests/assets/test-console.js',
+ requires : ['console-filters'],
+ skinnable: true
+ },
+
+ 'skin-sam-test-console': {
+ fullpath: '../../../common/tests/assets/test-console.css',
+ type : 'css'
+ }
+ },
+
+ useBrowserConsole: false
+}).use('node-attrs-benchmark', 'test-console', function (Y) {
+ var suite = Y.BenchmarkSuite,
+ start = Y.one('#start');
+
+ suite.on('start', function () {
+ start.set('disabled', true);
+ Y.log('Starting benchmarks.');
+ });
+
+ suite.on('cycle', function (bench) {
+ Y.log(String(bench));
+ });
+
+ suite.on('complete', function () {
+ start.set('disabled', false);
+ Y.log('Finished.');
+ });
+
+ start.on('click', function () {
+ suite.run(true);
+ });
+});
+</script>
+
+</body>
+</html>
View
114 src/node/tests/perf/node-core-benchmark.js
@@ -0,0 +1,114 @@
+YUI.add('node-core-benchmark', function (Y) {
+ var suite = Y.BenchmarkSuite = new Benchmark.Suite(),
+ testNode = Y.one('#test-node'),
+ bodyNode = Y.one('body'),
+ testEmpty = Y.one('#test-empty'),
+ testRemove = Y.one('#test-remove');
+
+
+ suite.add('new Y.Node("#test-node")', function() {
+ var node = new Y.Node('#test-node');
+ });
+
+ suite.add('new Y.Node("#test-node").destroy()', function() {
+ var node = new Y.Node('#test-node');
+ node.destroy();
+ });
+
+ suite.add('new Y.Node("#test-node").destroy(true)', function() {
+ var node = new Y.Node('#test-node');
+ node.destroy(true);
+ });
+
+ suite.add('node.get()', function() {
+ testNode.get('nodeName');
+ });
+
+ suite.add('node.getAttrs()', function() {
+ testNode.getAttrs(['nodeName', 'nodeType']);
+ });
+
+ suite.add('node.set()', function() {
+ testNode.set('id', 'foo');
+ });
+
+ suite.add('node.setAttrs()', function() {
+ testNode.setAttrs({
+ title: 'foo',
+ id: 'bar'
+ });
+ });
+
+ suite.add('node.compareTo()', function() {
+ testNode.compareTo(testNode);
+ });
+
+ suite.add('node.inDoc()', function() {
+ testNode.inDoc();
+ });
+
+ suite.add('node.getById()', function() {
+ bodyNode.getById('log');
+ });
+
+ suite.add('node.ancestor()', function() {
+ testNode.ancestor();
+ });
+
+ suite.add('node.ancestor(body)', function() {
+ testNode.ancestor('body');
+ });
+
+ suite.add('node.ancestors(html, body)', function() {
+ testNode.ancestors('html, body');
+ });
+
+ suite.add('node.previous()', function() {
+ testNode.previous();
+ });
+
+ suite.add('node.previous("div")', function() {
+ testNode.previous('div');
+ });
+
+ suite.add('node.next()', function() {
+ testNode.next();
+ });
+
+ suite.add('node.next("div")', function() {
+ testNode.next('div');
+ });
+
+ suite.add('node.siblings()', function() {
+ testNode.siblings();
+ });
+
+ suite.add('node.siblings("div")', function() {
+ testNode.siblings('div');
+ });
+
+ suite.add('node.one("div")', function() {
+ bodyNode.one('div');
+ });
+
+ suite.add('node.all("div")', function() {
+ bodyNode.all('div');
+ });
+
+ suite.add('node.test("div")', function() {
+ testNode.test('div');
+ });
+
+ suite.add('node.remove()', function() {
+ testRemove.remove();
+ });
+
+ suite.add('node.empty()', function() {
+ testEmpty.empty(true);
+ });
+
+ suite.add('node.invoke("getElementsByTagName", "div")', function() {
+ testNode.invoke('getElementsByTagName', 'div');
+ });
+
+}, '@VERSION@', {requires: ['node-core']});
View
79 src/node/tests/perf/node-core.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Benchmarks</title>
+</head>
+<body class="yui3-skin-sam">
+
+<p><button id="start">Start Benchmarks</button></p>
+
+<div id="log"></div>
+<div id="test-previous"></div>
+<div id="test-node"></div>
+<div id="test-next"></div>
+<div id="test-remove"></div>
+<div id="test-empty">
+ <div>
+ <div>
+ <span>
+ <em>
+ <strong>
+ </strong>
+ </em>
+ </span>
+ </div>
+ </div>
+</div>
+
+<applet code="nano" archive="https://github.com/bestiejs/benchmark.js/raw/v1.0.0/nano.jar" style="display: none;"></applet>
+<script src="http://pieisgood.org/misc/benchmark/benchmark.js"></script>
+
+<script src="../../../../build/yui/yui.js"></script>
+<script>
+var Y = YUI({
+ modules: {
+ 'node-core-benchmark': {
+ fullpath: 'node-core-benchmark.js',
+ requires: ['node-core']
+ },
+
+ 'test-console': {
+ fullpath : '../../../common/tests/assets/test-console.js',
+ requires : ['console-filters'],
+ skinnable: true
+ },
+
+ 'skin-sam-test-console': {
+ fullpath: '../../../common/tests/assets/test-console.css',
+ type : 'css'
+ }
+ },
+
+ useBrowserConsole: false
+}).use('node-core-benchmark', 'test-console', function (Y) {
+ var suite = Y.BenchmarkSuite,
+ start = Y.one('#start');
+
+ suite.on('start', function () {
+ start.set('disabled', true);
+ Y.log('Starting benchmarks.');
+ });
+
+ suite.on('cycle', function (bench) {
+ Y.log(String(bench));
+ });
+
+ suite.on('complete', function () {
+ start.set('disabled', false);
+ Y.log('Finished.');
+ });
+
+ start.on('click', function () {
+ suite.run(true);
+ });
+});
+</script>
+
+</body>
+</html>
View
46 src/node/tests/perf/node-create-benchmark.js
@@ -0,0 +1,46 @@
+YUI.add('node-create-benchmark', function (Y) {
+ var suite = Y.BenchmarkSuite = new Benchmark.Suite(),
+ testNode = Y.one('#test-node'),
+ testBefore = Y.one('#test-before'),
+ testAppendTo = Y.one('#test-append'),
+ bodyNode = Y.one('body');
+
+
+ suite.add('Y.Node.create("<div/>")', function() {
+ var node = Y.Node.create('<div/>');
+ });
+
+ suite.add('node.append()', function() {
+ bodyNode.append(testNode);
+ });
+
+ suite.add('node.insert())', function() {
+ bodyNode.insert(testNode);
+ });
+
+ suite.add('node.prepend()', function() {
+ bodyNode.prepend(testNode);
+ });
+
+ suite.add('node.appendChild()', function() {
+ bodyNode.appendChild(testNode);
+ });
+
+ suite.add('node.insertBefore())', function() {
+ bodyNode.insertBefore(testNode, testBefore);
+ });
+
+ suite.add('node.appendTo())', function() {
+ testAppendTo.appendTo(bodyNode);
+ });
+
+ suite.add('node.setHTML("<div/>"))', function() {
+ testNode.setHTML('<div/>');
+ });
+
+ suite.add('node.getHTML())', function() {
+ testNode.getHTML();
+ });
+
+
+}, '@VERSION@', {requires: ['node-base']});
View
66 src/node/tests/perf/node-create.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Benchmarks</title>
+</head>
+<body class="yui3-skin-sam">
+
+<p><button id="start">Start Benchmarks</button></p>
+
+<div id="log"></div>
+<div id="test-before"></div>
+<div id="test-node"></div>
+<div id="test-append"></div>
+
+<applet code="nano" archive="https://github.com/bestiejs/benchmark.js/raw/v1.0.0/nano.jar" style="display: none;"></applet>
+<script src="http://pieisgood.org/misc/benchmark/benchmark.js"></script>
+
+<script src="../../../../build/yui/yui.js"></script>
+<script>
+var Y = YUI({
+ modules: {
+ 'node-create-benchmark': {
+ fullpath: 'node-create-benchmark.js',
+ requires: ['node-base']
+ },
+
+ 'test-console': {
+ fullpath : '../../../common/tests/assets/test-console.js',
+ requires : ['console-filters'],
+ skinnable: true
+ },
+
+ 'skin-sam-test-console': {
+ fullpath: '../../../common/tests/assets/test-console.css',
+ type : 'css'
+ }
+ },
+
+ useBrowserConsole: false
+}).use('node-create-benchmark', 'test-console', function (Y) {
+ var suite = Y.BenchmarkSuite,
+ start = Y.one('#start');
+
+ suite.on('start', function () {
+ start.set('disabled', true);
+ Y.log('Starting benchmarks.');
+ });
+
+ suite.on('cycle', function (bench) {
+ Y.log(String(bench));
+ });
+
+ suite.on('complete', function () {
+ start.set('disabled', false);
+ Y.log('Finished.');
+ });
+
+ start.on('click', function () {
+ suite.run(true);
+ });
+});
+</script>
+
+</body>
+</html>
View
22 src/node/tests/perf/node-data-benchmark.js
@@ -0,0 +1,22 @@
+YUI.add('node-data-benchmark', function (Y) {
+ var suite = Y.BenchmarkSuite = new Benchmark.Suite(),
+ testNode = Y.one('#test-node');
+
+
+ suite.add('node.setData("foo", "foo data")', function() {
+ testNode.setData('foo', 'foo data');
+ });
+
+ suite.add('node.getData("foo")', function() {
+ testNode.getData('foo');
+ });
+
+ suite.add('node.clearData("foo")', function() {
+ testNode.clearData('foo');
+ });
+
+ suite.add('node.clearData()', function() {
+ testNode.clearData();
+ });
+
+}, '@VERSION@', {requires: ['node-base']});
View
64 src/node/tests/perf/node-data.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Benchmarks</title>
+</head>
+<body class="yui3-skin-sam">
+
+<p><button id="start">Start Benchmarks</button></p>
+
+<div id="log"></div>
+<div id="test-node"></div>
+
+<applet code="nano" archive="https://github.com/bestiejs/benchmark.js/raw/v1.0.0/nano.jar" style="display: none;"></applet>
+<script src="http://pieisgood.org/misc/benchmark/benchmark.js"></script>
+
+<script src="../../../../build/yui/yui.js"></script>
+<script>
+var Y = YUI({
+ modules: {
+ 'node-data-benchmark': {
+ fullpath: 'node-data-benchmark.js',
+ requires: ['node-base']
+ },
+
+ 'test-console': {
+ fullpath : '../../../common/tests/assets/test-console.js',
+ requires : ['console-filters'],
+ skinnable: true
+ },
+
+ 'skin-sam-test-console': {
+ fullpath: '../../../common/tests/assets/test-console.css',
+ type : 'css'
+ }
+ },
+
+ useBrowserConsole: false
+}).use('node-data-benchmark', 'test-console', function (Y) {
+ var suite = Y.BenchmarkSuite,
+ start = Y.one('#start');
+
+ suite.on('start', function () {
+ start.set('disabled', true);
+ Y.log('Starting benchmarks.');
+ });
+
+ suite.on('cycle', function (bench) {
+ Y.log(String(bench));
+ });
+
+ suite.on('complete', function () {
+ start.set('disabled', false);
+ Y.log('Finished.');
+ });
+
+ start.on('click', function () {
+ suite.run(true);
+ });
+});
+</script>
+
+</body>
+</html>

0 comments on commit 12c85a3

Please sign in to comment.
Something went wrong with that request. Please try again.