Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] updated the benchmarks to the latest versions.

  • Loading branch information...
commit d6b549df2ea4dc75e8a9ae6d806e305f83d66b64 1 parent 12b912c
Arnout Kazemier authored
Showing with 27 additions and 17 deletions.
  1. +2 −1  benchmark/package.json
  2. +25 −16 benchmark/run.js
3  benchmark/package.json
View
@@ -6,7 +6,8 @@
"microtime": ""
, "benchmark": ""
, "useragent": "0.1.2"
- , "ua-parser": "0.2.3"
+ , "ua-parser": "0.3.1"
, "useragent_parser": "1.0.0"
+ , "useragent-parser": "0.1.1"
}
}
41 benchmark/run.js
View
@@ -1,7 +1,8 @@
+'use strict';
+
/**
- * Benchmark dependencies
+ * Benchmark dependencies.
*/
-
var microtime = require('microtime')
, benchmark = require('benchmark')
, yaml = require('yamlparser')
@@ -9,30 +10,31 @@ var microtime = require('microtime')
, fs = require('fs');
/**
- * Useragent parsers
+ * Useragent parsers.
*/
-
var useragent2 = require('../')
, useragent = require('useragent')
, uaparser = require('ua-parser')
- , useragent_parser = require('useragent_parser');
+ , useragent_parser = require('useragent_parser')
+ , useragent_parser2 = require('useragent-parser');
/**
- * Setup the test-files
+ * Setup the test-files.
*/
-
var useragentlist = path.join(__dirname, '..', 'tests', 'fixtures', 'testcases.yaml')
, yammy = yaml.eval(fs.readFileSync(useragentlist).toString()).test_cases
- , testcases = yammy.map(function (test) { return test.user_agent_string })
+ , testcases = yammy.map(function (test) {
+ return test.user_agent_string;
+ })
, length = testcases.length;
/**
* Setup the benchmark
*/
-
var froomfroom = new benchmark.Suite;
-froomfroom.add('useragent2', function () {
+froomfroom
+.add('useragent latest', function () {
for (var i = 0; i < length; i++ ) {
useragent2.parse(testcases[i]);
}
@@ -47,19 +49,26 @@ froomfroom.add('useragent2', function () {
useragent_parser.parse(testcases[i]);
}
})
+.add('useragent-parser', function (){
+ for (var i = 0; i < length; i++ ) {
+ useragent_parser2.parse(testcases[i]);
+ }
+})
.add('ua-parser', function () {
for (var i = 0; i < length; i++ ) {
uaparser.parse(testcases[i]);
}
})
-.on('cycle', function (bench, details) {
+.on('cycle', function (event) {
+ var details = event.target;
+
console.log('Executed benchmark (%s)', details.name);
console.log('Count (%d), Cycles (%d), Elapsed (%d), Hz (%d)\n'
- , details.count
- , details.cycles
- , details.times.elapsed
- , details.hz
- );
+ , details.count
+ , details.cycles
+ , details.times.elapsed
+ , details.hz
+ );
})
.on('complete', function () {
console.log(this.filter('fastest').pluck('name') + ' has/have the fastest parser');
Please sign in to comment.
Something went wrong with that request. Please try again.