11import * as chrome from 'selenium-webdriver/chrome'
22import { Builder , WebDriver , promise , logging } from 'selenium-webdriver'
3- import { BenchmarkType , Benchmark , benchmarks } from './benchmarks'
3+ import { BenchmarkType , Benchmark , benchmarks , fileName } from './benchmarks'
44import { forProm } from './webdriverAccess'
55
66import * as fs from 'fs' ;
77import * as yargs from 'yargs' ;
8- import { JSONResult , config } from './common'
8+ import { JSONResult , config , FrameworkData , frameworks } from './common'
99var chromedriver :any = require ( 'chromedriver' ) ;
1010var jStat :any = require ( 'jstat' ) . jStat ;
1111
@@ -55,42 +55,6 @@ function readLogs(driver: WebDriver): promise.Promise<Timingresult[]> {
5555 } ) ;
5656}
5757
58- interface FrameworkData {
59- name : string ;
60- uri : string ;
61- }
62-
63- function f ( name : string , uri : string = null ) : FrameworkData
64- {
65- return { name, uri : uri ? uri : name } ;
66- }
67-
68- let frameworks = [
69- f ( "angular-v1.5.8" ) ,
70- f ( "angular-v2.0.0-rc5" ) ,
71- f ( "aurelia-v1.0.0" , "aurelia-v1.0.0/dist" ) ,
72- f ( "bobril-v4.44.1" ) ,
73- f ( "cyclejs-v7.0.0" ) ,
74- f ( "domvm-v1.2.10" ) ,
75- f ( "inferno-v0.7.26" ) ,
76- f ( "kivi-v1.0.0-rc0" ) ,
77- f ( "mithril-v0.2.5" ) ,
78- f ( "mithril-v1.0.0-alpha" ) ,
79- f ( "plastiq-v1.33.0" ) ,
80- f ( "preact-v5.7.0" ) ,
81- f ( "ractive-v0.7.3" ) ,
82- f ( "ractive-edge" ) ,
83- f ( "react-lite-v0.15.17" ) ,
84- f ( "react-v15.3.1" ) ,
85- f ( "react-v15.3.1-mobX-v2.5.0" ) ,
86- f ( "riot-v2.6.1" ) ,
87- f ( "tsers-v1.0.0" ) ,
88- f ( "vanillajs" ) ,
89- f ( "vidom-v0.3.18" ) ,
90- f ( "vue-v1.0.26" ) ,
91- f ( "vue-v2.0.0-beta1" )
92- ] ;
93-
9458function buildDriver ( ) {
9559 let logPref = new logging . Preferences ( ) ;
9660 logPref . setLevel ( logging . Type . PERFORMANCE , logging . Level . ALL ) ;
@@ -149,7 +113,7 @@ interface Result {
149113 benchmark : Benchmark
150114}
151115
152- function writeResult ( res : Result ) {
116+ function writeResult ( res : Result , dir : string ) {
153117 let benchmark = res . benchmark ;
154118 let framework = res . framework . name ;
155119 let data = res . results ;
@@ -167,10 +131,10 @@ function writeResult(res: Result) {
167131 "geometricMean" : s . geomean ( ) ,
168132 "standardDeviation" : s . stdev ( )
169133 }
170- fs . writeFileSync ( `results/ ${ framework } _ ${ benchmark . id } .json ` , JSON . stringify ( result ) , { encoding : "utf8" } ) ;
134+ fs . writeFileSync ( `${ dir } / ${ fileName ( framework , benchmark ) } ` , JSON . stringify ( result ) , { encoding : "utf8" } ) ;
171135}
172136
173- function runBench ( frameworkNames : string [ ] , benchmarkNames : string [ ] ) : promise . Promise < any > {
137+ function runBench ( frameworkNames : string [ ] , benchmarkNames : string [ ] , dir : string ) : promise . Promise < any > {
174138 let runFrameworks = frameworks . filter ( f => frameworkNames . some ( name => f . name . indexOf ( name ) > - 1 ) ) ;
175139 let runBenchmarks = benchmarks . filter ( b => benchmarkNames . some ( name => b . id . toLowerCase ( ) . indexOf ( name ) > - 1 ) ) ;
176140 console . log ( "Frameworks that will be benchmarked" , runFrameworks ) ;
@@ -196,7 +160,7 @@ function runBench(frameworkNames: string[], benchmarkNames: string[]): promise.P
196160 } )
197161 . then ( results => reduceBenchmarkResults ( benchmark , results ) )
198162 . then ( results => {
199- writeResult ( { framework : framework , results : results , benchmark : benchmark } ) ;
163+ writeResult ( { framework : framework , results : results , benchmark : benchmark } , dir ) ;
200164 } )
201165 . thenFinally ( ( ) => { console . log ( "QUIT" ) ; driver . quit ( ) ; } )
202166 } ) ;
@@ -205,17 +169,24 @@ function runBench(frameworkNames: string[], benchmarkNames: string[]): promise.P
205169let args = yargs ( process . argv )
206170. usage ( "$0 [--framework Framework1,Framework2,...] [--benchmark Benchmark1,Benchmark2,...]" )
207171. help ( 'help' )
172+ . default ( 'check' , 'false' )
208173. array ( "framework" ) . array ( "benchmark" ) . argv ;
209174
175+ console . log ( args ) ;
176+
210177let runBenchmarks = args . benchmark && args . benchmark . length > 0 ? args . benchmark : [ "" ] ;
211178let runFrameworks = args . framework && args . framework . length > 0 ? args . framework : [ "" ] ;
212179
213- if ( ! fs . existsSync ( "results" ) )
214- fs . mkdirSync ( "results" ) ;
180+ let dir = args . check === 'true' ? "results_check" : "results"
181+
182+ console . log ( "target directory" , dir ) ;
183+
184+ if ( ! fs . existsSync ( dir ) )
185+ fs . mkdirSync ( dir ) ;
215186
216187if ( args . help ) {
217188 yargs . showHelp ( ) ;
218189} else {
219- runBench ( runFrameworks , runBenchmarks ) ;
190+ runBench ( runFrameworks , runBenchmarks , dir ) ;
220191}
221192
0 commit comments