@@ -43,9 +43,9 @@ def end(self):
4343 @end .setter
4444 def end (self , value ):
4545 self ._validate_positive_number (value )
46- if value <= self .start :
46+ if value < self .start :
4747 raise ValueError (
48- "Profile end value must be bigger than {}, got {}" .format (self .start , value ))
48+ "Profile end value must be greater than or equal to {}, got {}" .format (self .start , value ))
4949 self ._end = value
5050 # this is the total cpu time spent in this application since start, not just the overhead
5151 self .cpu_time_seconds = time .process_time () - self ._start_process_time
@@ -63,7 +63,7 @@ def get_active_millis_since_start(self):
6363
6464 def add (self , sample ):
6565 """
66- Merge Sample into the call graph.
66+ Merge Sample into the call graph and update profile end time pointing to the last sample time .
6767 """
6868 self .total_attempted_sample_threads_count += \
6969 sample .attempted_sample_threads_count
@@ -74,6 +74,8 @@ def add(self, sample):
7474 for stack in sample .stacks :
7575 self ._insert_stack (stack )
7676
77+ self .end = current_milli_time (clock = self ._clock )
78+
7779 def set_overhead_ms (self , duration_timedelta ):
7880 """
7981 The overhead is the total cpu time spent profiling since start. It is measured by a Timer object and only passed
@@ -138,6 +140,6 @@ def average_thread_weight(self):
138140 def __str__ (self ):
139141 return "Profile(profiling_group_name=" + self .profiling_group_name \
140142 + ", start=" + to_iso (self .start ) \
141- + ', end=' + to_iso (self .end ) \
143+ + ', end=' + "none" if self . end is None else to_iso (self .end ) \
142144 + ', duration_ms=' + str (self .get_active_millis_since_start ()) \
143145 + ')'
0 commit comments