Skip to content

Commit

Permalink
Add benchmark test suite
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
nwoltman committed Apr 17, 2016
1 parent d7665c1 commit ffd348e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
13 changes: 13 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# String Natural Compare Benchmark Tests

First update dependencies before running tests:

```sh
npm install # or npm update if already installed
```

Run tests:

```sh
node run
```
8 changes: 8 additions & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"description": "Dependencies for string-natural-compare bechmarking",
"license": "UNLICENSED",
"dependencies": {
"benchmark": "^2.1.0",
"string-natural-compare": "nwoltman/string-natural-compare"
}
}
72 changes: 72 additions & 0 deletions benchmark/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* eslint-disable no-console */

'use strict';

var Benchmark = require('benchmark');

var naturalCompareMaster = require('string-natural-compare');
var naturalCompareCurrent = require('../');


new Benchmark.Suite()

.add('no numbers master', function() {
naturalCompareMaster('file.txt', 'otherFile.txt');
naturalCompareMaster('otherFile.txt', 'file.txt');
})
.add('no numbers current', function() {
naturalCompareCurrent('file.txt', 'otherFile.txt');
naturalCompareCurrent('otherFile.txt', 'file.txt');
})

.add('common numbers master', function() {
naturalCompareMaster('a2.txt', 'a10.txt');
naturalCompareMaster('a10.txt', 'a2.txt');
})
.add('common numbers current', function() {
naturalCompareCurrent('a2.txt', 'a10.txt');
naturalCompareCurrent('a10.txt', 'a2.txt');
})

.add('big numbers master', function() {
naturalCompareMaster('1165874568735487968325787328996865', '265812277985321589735871687040841');
naturalCompareMaster('265812277985321589735871687040841', '1165874568735487968325787328996865');
})
.add('big numbers current', function() {
naturalCompareCurrent('1165874568735487968325787328996865', '265812277985321589735871687040841');
naturalCompareCurrent('265812277985321589735871687040841', '1165874568735487968325787328996865');
})

.on('cycle', function(event) {
console.log(String(event.target));
})
.run();


naturalCompareMaster.alphabet = 'ABDEFGHIJKLMNOPRSŠZŽTUVÕÄÖÜXYabdefghijklmnoprsšzžtuvõäöüxy';
naturalCompareCurrent.alphabet = 'ABDEFGHIJKLMNOPRSŠZŽTUVÕÄÖÜXYabdefghijklmnoprsšzžtuvõäöüxy';

new Benchmark.Suite()

.add('custom alphabet included characters master', function() {
naturalCompareMaster('š.txt', 'z.txt');
naturalCompareMaster('z.txt', 'š.txt');
})
.add('custom alphabet included characters current', function() {
naturalCompareCurrent('š.txt', 'z.txt');
naturalCompareCurrent('z.txt', 'š.txt');
})

.add('custom alphabet missing characters master', function() {
naturalCompareMaster('é.txt', 'à.txt');
naturalCompareMaster('à.txt', 'é.txt');
})
.add('custom alphabet missing characters current', function() {
naturalCompareCurrent('é.txt', 'à.txt');
naturalCompareCurrent('à.txt', 'é.txt');
})

.on('cycle', function(event) {
console.log(String(event.target));
})
.run();

0 comments on commit ffd348e

Please sign in to comment.