1-- 2-- Copyright 2020 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15 16SELECT RUN_METRIC('chrome/scroll_jank.sql') AS suppress_query_output; 17 18SELECT ( 19 -- There are only two valid scrolls (one additional scroll is missing a begin 20 -- and the other is missing an end). 21 SELECT COUNT(*) FROM joined_scroll_begin_and_end 22) AS total, 23( 24 -- Of the two valid scrolls 25 -- gesture_scroll_id: 2708 26 -- starts at: 544958000403 27 -- ends at: 545859896829 28 -- adds dur: 901896426 nanoseconds of scrolling. 29 -- 30 -- gesture_scroll_id: 2917 31 -- starts at: 546027000403 32 -- ends at: 546753574829 33 -- adds dur: 726574426 nanoseconds of scrolling. 34 -- This means we should have scroll_dur == 1628470852 35 SELECT SUM(scroll_dur) FROM ( 36 SELECT 37 gesture_scroll_id, max(maybe_gesture_end) - begin_ts AS scroll_dur 38 FROM scroll_jank 39 GROUP BY gesture_scroll_id 40 ) 41) AS scroll_dur, 42( 43 -- This can be verified by the following simple query to ensure the end result 44 -- in scroll_jank table is sane. The result should be 139. 45 -- SELECT 46 -- COUNT(*) 47 -- FROM slice 48 -- WHERE 49 -- name = "InputLatency::GestureScrollUpdate" AND 50 -- NOT EXTRACT_ARG(arg_set_id, 'chrome_latency_info.is_coalesced') AND 51 -- ( 52 -- EXTRACT_ARG(arg_set_id, 'chrome_latency_info.gesture_scroll_id') = 2708 53 -- OR 54 -- EXTRACT_ARG(arg_set_id, 'chrome_latency_info.gesture_scroll_id') = 2917 55 -- ) 56 SELECT COUNT(*) FROM scroll_jank 57) AS non_coalesced_updates, 58( 59 -- This can be verified by the following simple query as above but replace 60 -- COUNT(*) with SUM(dur). The result should be 3974685214. 61 SELECT SUM(dur) FROM scroll_jank 62) AS non_coalesced_dur, 63( 64 -- This was found by running the previous metric before porting on the 65 -- example trace. 66 SELECT COUNT(*) FROM scroll_jank WHERE jank 67) AS non_coalesced_janky_updates, 68( 69 -- This was found by running the previous metric before porting on the 70 -- example trace, and also manually summing them. 71 SELECT SUM(dur) FROM scroll_jank WHERE jank 72) AS non_coalesced_janky_dur, 73( 74 -- This is floor((non_coalesced_janky_dur/non_coalesced_dur) * 100) in SQLite. 75 SELECT 76 CAST((CAST((SELECT SUM(dur) FROM scroll_jank WHERE jank) AS FLOAT) / 77 CAST((SELECT SUM(dur) FROM scroll_jank) AS FLOAT)) * 100 AS INT) 78) AS janky_percentage, 79( 80 SELECT avg_vsync_interval FROM joined_scroll_begin_and_end 81) as avg_vsync_interval; 82 83