• lpy's avatar
    [Tracing] Fix inaccurate timer calculation in runtime statistics. · 92d9a56a
    lpy authored
    Previously we reset runtime counters and dump them when we enter, exit top level
    trace events respectively. However, there is gap between two top level trace
    events and runtime counters may be activated, resetting the counters makes the
    accumulated time inaccurate, and we may end up with negative time due to the
    nature of how we accumulate time.
    
    This patch fixes this problem by only resetting counters when there's no
    counters active, and before dump counters, we traverse current active counters
    to calculate their time, and then restart their timer.
    
    BUG=chromium:658145
    
    Review-Url: https://codereview.chromium.org/2457523002
    Cr-Commit-Position: refs/heads/master@{#40653}
    92d9a56a
counters.cc 11.5 KB