-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I had these benchmarks from the last time I did some perf research in this repo, so I thought maybe it was a good idea to have them in the repo itself, so other people can use them and you guys can verify if the perf is still good or you had any regression.
- Loading branch information
Showing
8 changed files
with
195 additions
and
1 deletion.
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,48 @@ | ||
const Benchmark = require('benchmark') | ||
const SemVer = require('../classes/semver') | ||
const suite = new Benchmark.Suite() | ||
|
||
const versions = ['1.0.3', '2.2.2', '2.3.0'] | ||
const versionToCompare = '1.0.2' | ||
const option1 = { includePrelease: true } | ||
const option2 = { includePrelease: true, loose: true } | ||
const option3 = { includePrelease: true, loose: true, rtl: true } | ||
|
||
for (const version of versions) { | ||
suite.add(`compare ${version} to ${versionToCompare}`, function () { | ||
const semver = new SemVer(version) | ||
semver.compare(versionToCompare) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add( | ||
`compare ${version} to ${versionToCompare} with option (${JSON.stringify(option1)})`, | ||
function () { | ||
const semver = new SemVer(version, option1) | ||
semver.compare(versionToCompare) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add(`compare ${version} to ${versionToCompare} with option (${JSON.stringify(option2)})`, | ||
function () { | ||
const semver = new SemVer(version, option2) | ||
semver.compare(versionToCompare) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add( | ||
`compare ${version} to ${versionToCompare} with option (${JSON.stringify(option3)})`, | ||
function () { | ||
const semver = new SemVer(version, option3) | ||
semver.compare(versionToCompare) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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,21 @@ | ||
const Benchmark = require('benchmark') | ||
const diff = require('../functions/diff') | ||
const suite = new Benchmark.Suite() | ||
|
||
const cases = [ | ||
['0.0.1', '0.0.1-pre', 'patch'], | ||
['0.0.1', '0.0.1-pre-2', 'patch'], | ||
['1.1.0', '1.1.0-pre', 'minor'], | ||
] | ||
|
||
for (const [v1, v2] of cases) { | ||
suite.add(`diff(${v1}, ${v2})`, function () { | ||
diff(v1, v2) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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,33 @@ | ||
const Benchmark = require('benchmark') | ||
const parseOptions = require('../internal/parse-options') | ||
const suite = new Benchmark.Suite() | ||
|
||
const options1 = { | ||
includePrerelease: true, | ||
} | ||
|
||
const options2 = { | ||
includePrerelease: true, | ||
loose: true, | ||
} | ||
|
||
const options3 = { | ||
includePrerelease: true, | ||
loose: true, | ||
rtl: false, | ||
} | ||
|
||
suite | ||
.add('includePrerelease', function () { | ||
parseOptions(options1) | ||
}) | ||
.add('includePrerelease + loose', function () { | ||
parseOptions(options2) | ||
}) | ||
.add('includePrerelease + loose + rtl', function () { | ||
parseOptions(options3) | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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,25 @@ | ||
const Benchmark = require('benchmark') | ||
const parse = require('../functions/parse') | ||
const { MAX_SAFE_INTEGER } = require('../internal/constants') | ||
const suite = new Benchmark.Suite() | ||
|
||
const cases = ['1.2.1', '1.2.2-4', '1.2.3-pre'] | ||
const invalidCases = [`${MAX_SAFE_INTEGER}0.0.0`, 'hello, world', 'xyz'] | ||
|
||
for (const test of cases) { | ||
suite.add(`parse(${test})`, function () { | ||
parse(test) | ||
}) | ||
} | ||
|
||
for (const test of invalidCases) { | ||
suite.add(`invalid parse(${test})`, function () { | ||
parse(test) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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,39 @@ | ||
const Benchmark = require('benchmark') | ||
const satisfies = require('../functions/satisfies') | ||
const suite = new Benchmark.Suite() | ||
|
||
const versions = ['1.0.3||^2.0.0', '2.2.2||~3.0.0', '2.3.0||<4.0.0'] | ||
const versionToCompare = '1.0.6' | ||
const option1 = { includePrelease: true } | ||
const option2 = { includePrelease: true, loose: true } | ||
const option3 = { includePrelease: true, loose: true, rtl: true } | ||
|
||
for (const version of versions) { | ||
suite.add(`satisfies(${versionToCompare}, ${version})`, function () { | ||
satisfies(versionToCompare, version) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option1)})`, function () { | ||
satisfies(versionToCompare, version, option1) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option2)})`, function () { | ||
satisfies(versionToCompare, version, option2) | ||
}) | ||
} | ||
|
||
for (const version of versions) { | ||
suite.add(`satisfies(${versionToCompare}, ${version}, ${JSON.stringify(option3)})`, function () { | ||
satisfies(versionToCompare, version, option3) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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,25 @@ | ||
const Benchmark = require('benchmark') | ||
const subset = require('../ranges/subset') | ||
const suite = new Benchmark.Suite() | ||
|
||
// taken from tests | ||
const cases = [ | ||
// everything is a subset of * | ||
['1.2.3', '*', true], | ||
['^1.2.3', '*', true], | ||
['^1.2.3-pre.0', '*', false], | ||
['^1.2.3-pre.0', '*', true, { includePrerelease: true }], | ||
['1 || 2 || 3', '*', true], | ||
] | ||
|
||
for (const [sub, dom] of cases) { | ||
suite.add(`subset(${sub}, ${dom})`, function () { | ||
subset(sub, dom) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.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