@@ -3,9 +3,9 @@ import { isPresent, isBlank, int, BaseException, StringWrapper, Math } from 'ang
33import { ListWrapper , StringMap , StringMapWrapper } from 'angular2/src/facade/collection' ;
44import { bind , OpaqueToken } from 'angular2/di' ;
55
6- import { WebDriverExtension } from '../web_driver_extension' ;
6+ import { WebDriverExtension , PerfLogFeatures } from '../web_driver_extension' ;
77import { Metric } from '../metric' ;
8- import { Options } from '../sample_options ' ;
8+ import { Options } from '../common_options ' ;
99
1010/**
1111 * A metric that reads out the performance log
@@ -21,6 +21,7 @@ export class PerflogMetric extends Metric {
2121 _measureCount :int ;
2222 _setTimeout :Function ;
2323 _microIterations :int ;
24+ _perfLogFeatures :PerfLogFeatures ;
2425
2526 /**
2627 * @param driverExtension
@@ -35,19 +36,24 @@ export class PerflogMetric extends Metric {
3536 this . _measureCount = 0 ;
3637 this . _setTimeout = setTimeout ;
3738 this . _microIterations = microIterations ;
39+ this . _perfLogFeatures = driverExtension . perfLogFeatures ( ) ;
3840 }
3941
4042 describe ( ) :StringMap {
4143 var res = {
42- 'script' : 'script execution time in ms' ,
43- 'render' : 'render time in ms' ,
44- 'gcTime' : 'gc time in ms' ,
45- 'gcAmount' : 'gc amount in kbytes' ,
46- 'majorGcTime' : 'time of major gcs in ms' ,
47- 'majorGcAmount' : 'amount of major gcs in kbytes'
44+ 'scriptTime' : 'script execution time in ms, including gc and render' ,
45+ 'pureScriptTime' : 'script execution time in ms, without gc nor render'
4846 } ;
47+ if ( this . _perfLogFeatures . render ) {
48+ res [ 'renderTime' ] = 'render time in and ouside of script in ms' ;
49+ }
50+ if ( this . _perfLogFeatures . gc ) {
51+ res [ 'gcTime' ] = 'gc time in and ouside of script in ms' ;
52+ res [ 'gcAmount' ] = 'gc amount in kbytes' ;
53+ res [ 'majorGcTime' ] = 'time of major gcs in ms' ;
54+ }
4955 if ( this . _microIterations > 0 ) {
50- res [ 'scriptMicroAvg ' ] = 'average script time for a micro iteration' ;
56+ res [ 'microScriptTimeAvg ' ] = 'average script time for a micro iteration' ;
5157 }
5258 return res ;
5359 }
@@ -120,17 +126,22 @@ export class PerflogMetric extends Metric {
120126
121127 _aggregateEvents ( events , markName ) {
122128 var result = {
123- 'script' : 0 ,
124- 'render' : 0 ,
125- 'gcTime' : 0 ,
126- 'gcAmount' : 0 ,
127- 'majorGcTime' : 0 ,
128- 'majorGcAmount' : 0
129+ 'scriptTime' : 0 ,
130+ 'pureScriptTime' : 0
129131 } ;
132+ if ( this . _perfLogFeatures . gc ) {
133+ result [ 'gcTime' ] = 0 ;
134+ result [ 'majorGcTime' ] = 0 ;
135+ result [ 'gcAmount' ] = 0 ;
136+ }
137+ if ( this . _perfLogFeatures . render ) {
138+ result [ 'renderTime' ] = 0 ;
139+ }
130140
131141 var markStartEvent = null ;
132142 var markEndEvent = null ;
133143 var gcTimeInScript = 0 ;
144+ var renderTimeInScript = 0 ;
134145
135146 var intervalStarts = { } ;
136147 events . forEach ( ( event ) => {
@@ -149,26 +160,30 @@ export class PerflogMetric extends Metric {
149160 var duration = event [ 'ts' ] - startEvent [ 'ts' ] ;
150161 intervalStarts [ name ] = null ;
151162 if ( StringWrapper . equals ( name , 'gc' ) ) {
152- var amount = ( startEvent [ 'args' ] [ 'usedHeapSize' ] - event [ 'args' ] [ 'usedHeapSize' ] ) / 1000 ;
153163 result [ 'gcTime' ] += duration ;
164+ var amount = ( startEvent [ 'args' ] [ 'usedHeapSize' ] - event [ 'args' ] [ 'usedHeapSize' ] ) / 1000 ;
154165 result [ 'gcAmount' ] += amount ;
155166 var majorGc = event [ 'args' ] [ 'majorGc' ] ;
156167 if ( isPresent ( majorGc ) && majorGc ) {
157168 result [ 'majorGcTime' ] += duration ;
158- result [ 'majorGcAmount' ] += amount ;
159169 }
160170 if ( isPresent ( intervalStarts [ 'script' ] ) ) {
161171 gcTimeInScript += duration ;
162172 }
163- } else if ( StringWrapper . equals ( name , 'script' ) || StringWrapper . equals ( name , 'render' ) ) {
164- result [ name ] += duration ;
173+ } else if ( StringWrapper . equals ( name , 'render' ) ) {
174+ result [ 'renderTime' ] += duration ;
175+ if ( isPresent ( intervalStarts [ 'script' ] ) ) {
176+ renderTimeInScript += duration ;
177+ }
178+ } else if ( StringWrapper . equals ( name , 'script' ) ) {
179+ result [ 'scriptTime' ] += duration ;
165180 }
166181 }
167182 }
168183 } ) ;
169- result [ 'script ' ] -= gcTimeInScript ;
184+ result [ 'pureScriptTime ' ] = result [ 'scriptTime' ] - gcTimeInScript - renderTimeInScript ;
170185 if ( this . _microIterations > 0 ) {
171- result [ 'scriptMicroAvg ' ] = result [ 'script ' ] / this . _microIterations ;
186+ result [ 'microScriptTimeAvg ' ] = result [ 'scriptTime ' ] / this . _microIterations ;
172187 }
173188 return isPresent ( markStartEvent ) && isPresent ( markEndEvent ) ? result : null ;
174189 }
@@ -183,7 +198,8 @@ var _MARK_NAME_PREFIX = 'benchpress';
183198var _SET_TIMEOUT = new OpaqueToken ( 'PerflogMetric.setTimeout' ) ;
184199var _BINDINGS = [
185200 bind ( PerflogMetric ) . toFactory (
186- ( driverExtension , setTimeout , microIterations ) => new PerflogMetric ( driverExtension , setTimeout , microIterations ) ,
201+ ( driverExtension , setTimeout , microIterations ) =>
202+ new PerflogMetric ( driverExtension , setTimeout , microIterations ) ,
187203 [ WebDriverExtension , _SET_TIMEOUT , Options . MICRO_ITERATIONS ]
188204 ) ,
189205 bind ( _SET_TIMEOUT ) . toValue ( ( fn , millis ) => PromiseWrapper . setTimeout ( fn , millis ) ) ,
0 commit comments