@@ -24,6 +24,7 @@ public class PerformanceReportBuilder
2424 readonly IGetsValueFormatter valueFormatterProvider ;
2525 readonly IFormatsReportFragment formatter ;
2626 readonly IGetsContentType contentTypeProvider ;
27+ readonly IMeasuresTime reportTimer ;
2728
2829 /// <summary>
2930 /// Gets a value indicating whether or not this builder has a 'current' performable that it is building.
@@ -84,6 +85,7 @@ public void ActorCreated(Actor actor)
8485 {
8586 ActorName = actor . Name ,
8687 Report = string . Format ( ReportStrings . ActorCreatedFormat , actor . Name ) ,
88+ Started = reportTimer . GetCurrentTime ( ) ,
8789 } ) ;
8890 }
8991
@@ -102,6 +104,7 @@ public void ActorGainedAbility(Actor actor, object ability)
102104 {
103105 ActorName = actor . Name ,
104106 Report = reportText ,
107+ Started = reportTimer . GetCurrentTime ( ) ,
105108 } ) ;
106109 }
107110
@@ -120,6 +123,7 @@ public void ActorSpotlit(Actor actor)
120123 {
121124 ActorName = actor . Name ,
122125 Report = string . Format ( ReportStrings . ActorSpotlitFormat , actor . Name ) ,
126+ Started = reportTimer . GetCurrentTime ( ) ,
123127 } ) ;
124128 }
125129
@@ -136,6 +140,7 @@ public void SpotlightTurnedOff()
136140 NewPerformableList . Add ( new SpotlightTurnedOffReport
137141 {
138142 Report = ReportStrings . SpotlightTurnedOff ,
143+ Started = reportTimer . GetCurrentTime ( ) ,
139144 } ) ;
140145 }
141146
@@ -172,6 +177,7 @@ public void BeginPerformable(object performable, Actor actor, string performance
172177 PerformableType = performable . GetType ( ) . FullName ,
173178 ActorName = actor . Name ,
174179 PerformancePhase = performancePhase ,
180+ Started = reportTimer . GetCurrentTime ( ) ,
175181 } ;
176182
177183 NewPerformableList . Add ( performableReport ) ;
@@ -235,6 +241,7 @@ public void EndPerformable(object performable, Actor actor)
235241 CurrentPerformable . Report = performable is ICanReport reporter
236242 ? reporter . GetReportFragment ( actor , formatter ) . FormattedFragment
237243 : string . Format ( ReportStrings . FallbackReportFormat , actor . Name , performable . GetType ( ) . FullName ) ;
244+ CurrentPerformable . Ended = reportTimer . GetCurrentTime ( ) ;
238245 performableStack . Pop ( ) ;
239246 }
240247
@@ -254,6 +261,7 @@ public void RecordFailureForCurrentPerformable(Exception exception)
254261 {
255262 CurrentPerformable . Exception = exception . ToString ( ) ;
256263 CurrentPerformable . ExceptionIsFromConsumedPerformable = exception is PerformableException ;
264+ CurrentPerformable . Ended = reportTimer . GetCurrentTime ( ) ;
257265 performableStack . Pop ( ) ;
258266 }
259267
@@ -266,21 +274,26 @@ public void RecordFailureForCurrentPerformable(Exception exception)
266274 /// <param name="valueFormatterProvider">A value formatter factory</param>
267275 /// <param name="formatter">A report-fragment formatter</param>
268276 /// <param name="contentTypeProvider">A content type provider service</param>
277+ /// <param name="reportTimer">A report timer</param>
269278 /// <exception cref="ArgumentNullException">If any parameter is <see langword="null" />.</exception>
270279 public PerformanceReportBuilder ( List < IdentifierAndNameModel > namingHierarchy ,
271280 IGetsValueFormatter valueFormatterProvider ,
272281 IFormatsReportFragment formatter ,
273- IGetsContentType contentTypeProvider )
282+ IGetsContentType contentTypeProvider ,
283+ IMeasuresTime reportTimer )
274284 {
275285 if ( namingHierarchy is null )
276286 throw new ArgumentNullException ( nameof ( namingHierarchy ) ) ;
277287
278288 this . valueFormatterProvider = valueFormatterProvider ?? throw new ArgumentNullException ( nameof ( valueFormatterProvider ) ) ;
279289 this . formatter = formatter ?? throw new ArgumentNullException ( nameof ( formatter ) ) ;
280290 this . contentTypeProvider = contentTypeProvider ?? throw new ArgumentNullException ( nameof ( contentTypeProvider ) ) ;
291+ this . reportTimer = reportTimer ?? throw new ArgumentNullException ( nameof ( reportTimer ) ) ;
292+
281293 report = new PerformanceReport
282294 {
283295 NamingHierarchy = namingHierarchy . ToList ( ) ,
296+ Started = reportTimer . GetCurrentTime ( ) ,
284297 } ;
285298 }
286299 }
0 commit comments