• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6from python.generators.diff_tests.testing import Path, DataPath, Metric
7from python.generators.diff_tests.testing import Csv, Json, TextProto
8from python.generators.diff_tests.testing import DiffTestBlueprint
9from python.generators.diff_tests.testing import TestSuite
10
11
12class ChromeStdlib(TestSuite):
13  # Chrome tasks.
14  def test_chrome_tasks(self):
15    return DiffTestBlueprint(
16        trace=DataPath(
17            'chrome_page_load_all_categories_not_extended.pftrace.gz'),
18        query="""
19        INCLUDE PERFETTO MODULE chrome.tasks;
20
21        SELECT full_name as name, task_type, count() AS count
22        FROM chrome_tasks
23        GROUP BY full_name, task_type
24        HAVING count >= 5
25        ORDER BY count DESC, name;
26        """,
27        out=Path('chrome_tasks.out'))
28
29  def test_top_level_java_choreographer_slices_top_level_java_chrome_tasks(
30      self):
31    return DiffTestBlueprint(
32        trace=DataPath('top_level_java_choreographer_slices'),
33        query="""
34        INCLUDE PERFETTO MODULE chrome.tasks;
35
36        SELECT
37          full_name,
38          task_type
39        FROM chrome_tasks
40        WHERE category = "toplevel,Java"
41        AND ts < 263904000000000
42        GROUP BY full_name, task_type;
43        """,
44        out=Path(
45            'top_level_java_choreographer_slices_top_level_java_chrome_tasks_test.out'
46        ))
47
48  # Chrome custom navigation event names
49  def test_chrome_custom_navigation_tasks(self):
50    return DiffTestBlueprint(
51        trace=DataPath('chrome_custom_navigation_trace.gz'),
52        query="""
53        INCLUDE PERFETTO MODULE chrome.tasks;
54
55        SELECT full_name, task_type, count() AS count
56        FROM chrome_tasks
57        WHERE full_name GLOB 'FrameHost::BeginNavigation*'
58          OR full_name GLOB 'FrameHost::DidCommitProvisionalLoad*'
59          OR full_name GLOB 'FrameHost::DidCommitSameDocumentNavigation*'
60          OR full_name GLOB 'FrameHost::DidStopLoading*'
61        GROUP BY full_name, task_type
62        ORDER BY count DESC
63        LIMIT 50;
64        """,
65        out=Csv("""
66        "full_name","task_type","count"
67        "FrameHost::BeginNavigation (SUBFRAME)","navigation_task",5
68        "FrameHost::DidStopLoading (SUBFRAME)","navigation_task",3
69        "FrameHost::BeginNavigation (PRIMARY_MAIN_FRAME)","navigation_task",1
70        "FrameHost::DidCommitProvisionalLoad (SUBFRAME)","navigation_task",1
71        """))
72
73  # Chrome custom navigation event names
74  def test_chrome_histograms(self):
75    return DiffTestBlueprint(
76        trace=DataPath('chrome_5672_histograms.pftrace.gz'),
77        query="""
78        INCLUDE PERFETTO MODULE chrome.histograms;
79
80        SELECT
81          name,
82          count() as count
83        FROM chrome_histograms
84        GROUP BY name
85        ORDER BY count DESC, name
86        LIMIT 20;
87        """,
88        out=Csv("""
89        "name","count"
90        "Net.QuicSession.AsyncRead",19207
91        "Net.QuicSession.NumQueuedPacketsBeforeWrite",19193
92        "RendererScheduler.QueueingDuration.NormalPriority",9110
93        "Net.OnTransferSizeUpdated.Experimental.OverridenBy",8525
94        "Compositing.Renderer.AnimationUpdateOnMissingPropertyNode",3489
95        "Net.QuicConnection.WritePacketStatus",3099
96        "Net.QuicSession.PacketWriteTime.Synchronous",3082
97        "Net.QuicSession.SendPacketSize.ForwardSecure",3012
98        "Net.URLLoaderThrottleExecutionTime.WillStartRequest",1789
99        "Net.URLLoaderThrottleExecutionTime.BeforeWillProcessResponse",1773
100        "Net.URLLoaderThrottleExecutionTime.WillProcessResponse",1773
101        "UMA.StackProfiler.SampleInOrder",1534
102        "GPU.SharedImage.ContentConsumed",1037
103        "Gpu.Rasterization.Raster.MSAASampleCountLog2",825
104        "Scheduling.Renderer.DeadlineMode",637
105        "Blink.CullRect.UpdateTime",622
106        "Scheduling.Renderer.BeginImplFrameLatency2",591
107        "Net.QuicSession.CoalesceStreamFrameStatus",551
108        "API.StorageAccess.AllowedRequests2",541
109        "Net.HttpResponseCode",541
110        """))
111
112  def test_speedometer(self):
113    return DiffTestBlueprint(
114        trace=DataPath('speedometer.perfetto_trace.gz'),
115        query="""
116        INCLUDE PERFETTO MODULE chrome.speedometer;
117
118        SELECT
119          iteration,
120          ts,
121          dur,
122          total,
123          format('%.1f', mean) AS mean,
124          format('%.1f', geomean) AS geomean,
125          format('%.1f', score) AS score,
126          num_measurements
127        FROM
128          chrome_speedometer_iteration,
129          (
130            SELECT iteration, COUNT(*) AS num_measurements
131            FROM chrome_speedometer_measure
132            GROUP BY iteration
133          )
134        USING (iteration)
135        ORDER BY iteration;
136        """,
137        out=Path('chrome_speedometer.out'))
138
139  # CPU power ups
140  def test_cpu_powerups(self):
141    return DiffTestBlueprint(
142        trace=DataPath('cpu_powerups_1.pb'),
143        query="""
144        INCLUDE PERFETTO MODULE chrome.cpu_powerups;
145        SELECT * FROM chrome_cpu_power_first_toplevel_slice_after_powerup;
146        """,
147        out=Csv("""
148        "slice_id","previous_power_state"
149        424,2
150        703,2
151        708,2
152        """))