-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74793d9
commit 1599530
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var benchmark = require('benchmark') | ||
var benchmarks = require('beautify-benchmark') | ||
|
||
/** | ||
* Globals for benchmark.js | ||
*/ | ||
|
||
global.fresh = require('..') | ||
|
||
var suite = new benchmark.Suite() | ||
|
||
suite.add({ | ||
name: 'star', | ||
minSamples: 100, | ||
fn: 'var val = fresh({ \'if-none-match\': \'*\' }, { etag: \'"foo"\' })' | ||
}) | ||
|
||
suite.add({ | ||
name: 'single etag', | ||
minSamples: 100, | ||
fn: 'var val = fresh({ \'if-none-match\': \'"foo"\' }, { etag: \'"foo"\' })' | ||
}) | ||
|
||
suite.add({ | ||
name: 'several etags', | ||
minSamples: 100, | ||
fn: 'var val = fresh({ \'if-none-match\': \'"foo", "bar", "fizz", "buzz"\' }, { etag: \'"buzz"\' })' | ||
}) | ||
|
||
suite.on('start', function onCycle (event) { | ||
process.stdout.write(' etag\n\n') | ||
}) | ||
|
||
suite.on('cycle', function onCycle (event) { | ||
benchmarks.add(event.target) | ||
}) | ||
|
||
suite.on('complete', function onComplete () { | ||
benchmarks.log() | ||
}) | ||
|
||
suite.run({async: false}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var spawn = require('child_process').spawn | ||
|
||
var exe = process.argv[0] | ||
var cwd = process.cwd() | ||
|
||
for (var dep in process.versions) { | ||
console.log(' %s@%s', dep, process.versions[dep]) | ||
} | ||
|
||
console.log('') | ||
|
||
runScripts(fs.readdirSync(__dirname)) | ||
|
||
function runScripts (fileNames) { | ||
var fileName = fileNames.shift() | ||
|
||
if (!fileName) return | ||
if (!/\.js$/i.test(fileName)) return runScripts(fileNames) | ||
if (fileName.toLowerCase() === 'index.js') return runScripts(fileNames) | ||
|
||
var fullPath = path.join(__dirname, fileName) | ||
|
||
console.log('> %s %s', exe, path.relative(cwd, fullPath)) | ||
|
||
var proc = spawn(exe, [fullPath], { | ||
'stdio': 'inherit' | ||
}) | ||
|
||
proc.on('exit', function () { | ||
runScripts(fileNames) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var benchmark = require('benchmark') | ||
var benchmarks = require('beautify-benchmark') | ||
|
||
/** | ||
* Globals for benchmark.js | ||
*/ | ||
|
||
global.fresh = require('..') | ||
|
||
var suite = new benchmark.Suite() | ||
|
||
suite.add({ | ||
name: 'not modified', | ||
minSamples: 100, | ||
fn: 'var val = fresh({ \'if-modified-since\': \'Fri, 01 Jan 2010 00:00:00 GMT\' }, { \'last-modified\': \'Sat, 01 Jan 2000 00:00:00 GMT\' })' | ||
}) | ||
|
||
suite.add({ | ||
name: 'modified', | ||
minSamples: 100, | ||
fn: 'var val = fresh({ \'if-modified-since\': \'Mon, 01 Jan 1990 00:00:00 GMT\' }, { \'last-modified\': \'Sat, 01 Jan 2000 00:00:00 GMT\' })' | ||
}) | ||
|
||
suite.on('start', function onCycle (event) { | ||
process.stdout.write(' modified\n\n') | ||
}) | ||
|
||
suite.on('cycle', function onCycle (event) { | ||
benchmarks.add(event.target) | ||
}) | ||
|
||
suite.on('complete', function onComplete () { | ||
benchmarks.log() | ||
}) | ||
|
||
suite.run({async: false}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters