• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2023 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#      http://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
16# Discarded events that do not get to GPU are invisible for UMA metric and
17# therefore should be excluded in trace-based metric. This tests ensures that's
18# the case.
19
20import synth_common
21
22from synth_common import ms_to_ns
23trace = synth_common.create_trace()
24
25
26class ChromeScrollHelper:
27
28  def __init__(self, trace, start_id, start_gesture_id):
29    self.trace = trace
30    self.id = start_id
31    self.gesture_id = start_gesture_id
32
33  def begin(self, from_ms, dur_ms):
34    self.trace.add_input_latency_event_slice(
35        "GestureScrollBegin",
36        ts=ms_to_ns(from_ms),
37        dur=ms_to_ns(dur_ms),
38        track=self.id,
39        trace_id=self.id,
40        gesture_scroll_id=self.gesture_id,
41    )
42    self.id += 1
43
44  def update(self, from_ms, dur_ms, gets_to_gpu=True):
45    self.trace.add_input_latency_event_slice(
46        "GestureScrollUpdate",
47        ts=ms_to_ns(from_ms),
48        dur=ms_to_ns(dur_ms),
49        track=self.id,
50        trace_id=self.id,
51        gesture_scroll_id=self.gesture_id,
52        gets_to_gpu=gets_to_gpu,
53        is_coalesced=False,
54    )
55    self.id += 1
56
57  def end(self, from_ms, dur_ms):
58    self.trace.add_input_latency_event_slice(
59        "GestureScrollEnd",
60        ts=ms_to_ns(from_ms),
61        dur=ms_to_ns(dur_ms),
62        track=self.id,
63        trace_id=self.id,
64        gesture_scroll_id=self.gesture_id)
65    self.id += 1
66    self.gesture_id += 1
67