@@ -4,45 +4,15 @@ const Benchmark = require('benchmark')
44const SemVer = require ( '../classes/semver' )
55const suite = new Benchmark . Suite ( )
66
7- const versions = [ '1.0.3' , '2.2.2' , '2.3.0' ]
8- const versionToCompare = '1.0.2'
9- const option1 = { includePrelease : true }
10- const option2 = { includePrelease : true , loose : true }
11- const option3 = { includePrelease : true , loose : true , rtl : true }
7+ const comparisons = require ( '../test/fixtures/comparisons' )
128
13- for ( const version of versions ) {
14- suite . add ( `compare ${ version } to ${ versionToCompare } ` , function ( ) {
15- const semver = new SemVer ( version )
16- semver . compare ( versionToCompare )
9+ for ( const [ v0 , v1 ] of comparisons ) {
10+ suite . add ( `compare ${ v0 } to ${ v1 } ` , function ( ) {
11+ const semver = new SemVer ( v0 )
12+ semver . compare ( v1 )
1713 } )
1814}
1915
20- for ( const version of versions ) {
21- suite . add (
22- `compare ${ version } to ${ versionToCompare } with option (${ JSON . stringify ( option1 ) } )` ,
23- function ( ) {
24- const semver = new SemVer ( version , option1 )
25- semver . compare ( versionToCompare )
26- } )
27- }
28-
29- for ( const version of versions ) {
30- suite . add ( `compare ${ version } to ${ versionToCompare } with option (${ JSON . stringify ( option2 ) } )` ,
31- function ( ) {
32- const semver = new SemVer ( version , option2 )
33- semver . compare ( versionToCompare )
34- } )
35- }
36-
37- for ( const version of versions ) {
38- suite . add (
39- `compare ${ version } to ${ versionToCompare } with option (${ JSON . stringify ( option3 ) } )` ,
40- function ( ) {
41- const semver = new SemVer ( version , option3 )
42- semver . compare ( versionToCompare )
43- } )
44- }
45-
4616suite
4717 . on ( 'cycle' , function ( event ) {
4818 console . log ( String ( event . target ) )
0 commit comments