Commit 6e5d813b authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[tools/perf] Fix power metric in the case of counter overflow

Change-Id: I11d1608458710b2a5ef91322dc65c7ade9645cf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228620Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#775069}
parent 64506e4b
...@@ -25,13 +25,20 @@ INSERT INTO power_counters VALUES ...@@ -25,13 +25,20 @@ INSERT INTO power_counters VALUES
-- Convert power counter data into table of events, where each event has -- Convert power counter data into table of events, where each event has
-- start timestamp, duration and the average power drain during its duration -- start timestamp, duration and the average power drain during its duration
-- in Watts. -- in Watts.
-- Note that power counters wrap around at 2^30, we take that into account
-- when computing average drain between counters.
CREATE VIEW drain_in_watts AS CREATE VIEW drain_in_watts AS
SELECT SELECT
name, name,
ts, ts,
LEAD(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts as dur, LEAD(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts as dur,
(LEAD(value) OVER (PARTITION BY track_id ORDER BY ts) - value) / CASE
(LEAD(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts) * 1e3 as drain_w WHEN LEAD(value) OVER (PARTITION BY track_id ORDER BY ts) >= value
THEN (LEAD(value) OVER (PARTITION BY track_id ORDER BY ts) - value)
ELSE (1<<30 + LEAD(value) OVER (PARTITION BY track_id ORDER BY ts) - value)
END /
(LEAD(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts) * 1e3
AS drain_w
FROM counter FROM counter
JOIN counter_track ON (counter.track_id = counter_track.id) JOIN counter_track ON (counter.track_id = counter_track.id)
WHERE WHERE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment