@@ -4,45 +4,15 @@ const Benchmark = require('benchmark')
4
4
const SemVer = require ( '../classes/semver' )
5
5
const suite = new Benchmark . Suite ( )
6
6
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' )
12
8
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 )
17
13
} )
18
14
}
19
15
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
-
46
16
suite
47
17
. on ( 'cycle' , function ( event ) {
48
18
console . log ( String ( event . target ) )
0 commit comments