Permalink
Browse files

Introduce rudimentary benchmark suite

Compare the performance of Cheerio at HEAD with jsdom [1] using jQuery.
Include a new GNU Make target: `bench`.

[1] https://github.com/tmpvar/jsdom
  • Loading branch information...
1 parent 09e0c07 commit c7a1d8e14c06378a79109b245d161989c8050e1b @jugglinmike jugglinmike committed Nov 30, 2013
Showing with 10,146 additions and 15 deletions.
  1. +3 −0 Makefile
  2. +2 −0 benchmark/.gitattributes
  3. +36 −0 benchmark/benchmark.js
  4. +1,191 −0 benchmark/documents/jquery.html
  5. +8,829 −0 benchmark/jquery-2.0.3.js
  6. +82 −0 benchmark/suite.js
  7. +0 −14 benchmarks/htmlparser.js
  8. +3 −1 package.json
View
@@ -16,4 +16,7 @@ test-cov: lib-cov
lib-cov:
@jscoverage lib lib-cov
+bench:
+ @./benchmark/benchmark.js
+
.PHONY: test build setup subl
@@ -0,0 +1,2 @@
+documents/* binary
+jquery*.js binary
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+var Suites = require('./suite');
+var suites = new Suites();
+
+var regexIdx = process.argv.indexOf('--regex') + 1;
+if (regexIdx > 0) {
+ if (regexIdx === process.argv.length) {
+ console.error('Error: the "--regex" option requires a value');
+ process.exit(1);
+ }
+ suites.filter(process.argv[regexIdx]);
+}
+
+suites.add('Select all', 'jquery.html', {
+ test: function($) { $('*').length; }
+});
+suites.add('Select some', 'jquery.html', {
+ test: function($) { $('li').length; }
+});
+suites.add('Toggle class', 'jquery.html', {
+ setup: function($) {
+ return $('li');
+ },
+ test: function($, $lis) {
+ $lis.toggleClass('foo');
+ }
+});
+suites.add('Create markup', 'jquery.html', {
+ setup: function($) {
+ return $('body');
+ },
+ test: function($, $body) {
+ $body.append(new Array(50).join('<div>'));
+ }
+});
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit c7a1d8e

Please sign in to comment.