Permalink
Browse files

Add node-screen benchmarks.

  • Loading branch information...
msweeney committed Jan 10, 2013
1 parent d9eb75e commit 6ba44018279a29bd4d1fd1c657ba10b5c07e542a
Showing with 119 additions and 0 deletions.
  1. +55 −0 src/node/tests/perf/node-screen-benchmark.js
  2. +64 −0 src/node/tests/perf/node-screen.html
@@ -0,0 +1,55 @@
+YUI.add('node-screen-benchmark', function (Y) {
+ var suite = Y.BenchmarkSuite = new Benchmark.Suite(),
+ testNode = Y.one('#test-node'),
+ bodyNode = Y.one('body');
+
+
+ suite.add('node.get("winWidth")', function() {
+ testNode.get('winWidth');
+ });
+
+ suite.add('node.get("winHeight")', function() {
+ testNode.get('winHeight');
+ });
+
+ suite.add('node.get("docWidth")', function() {
+ testNode.get('docWidth');
+ });
+
+ suite.add('node.get("docHeight")', function() {
+ testNode.get('docHeight');
+ });
+
+ suite.add('node.get("docScrollX")', function() {
+ testNode.get('docScrollX');
+ });
+
+ suite.add('node.get("docScrollY")', function() {
+ testNode.get('docScrollY');
+ });
+
+ suite.add('node.set("scrollLeft", 100)', function() {
+ testNode.set('scrollLeft', 100);
+ });
+
+ suite.add('node.get("scrollLeft")', function() {
+ testNode.get('scrollLeft');
+ });
+
+ suite.add('node.set("scrollTop", 100)', function() {
+ testNode.set('scrollTop', 100);
+ });
+
+ suite.add('node.get("scrollTop")', function() {
+ testNode.get('scrollTop');
+ });
+
+ suite.add('node.setXY([100, 200])', function() {
+ testNode.setXY([100, 200]);
+ });
+
+ suite.add('node.getXY()', function() {
+ testNode.setXY();
+ });
+
+}, '@VERSION@', {requires: ['node-screen']});
@@ -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-screen-benchmark': {
+ fullpath: 'node-screen-benchmark.js',
+ requires: ['node-screen']
+ },
+
+ '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-screen-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 6ba4401

Please sign in to comment.