• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2019 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
16from os import sys, path
17
18import synth_common
19
20# See gpu_counter_descriptor.proto
21MILLISECOND = 21
22SECOND = 22
23VERTEX = 25
24PIXEL = 26
25TRIANGLE = 27
26
27trace = synth_common.create_trace()
28
29# Add 3 counter specs.
30trace.add_gpu_counter_spec(
31    ts=1,
32    counter_id=31,
33    name="Vertex / Second",
34    description="Number of vertices per second",
35    unit_numerators=[VERTEX],
36    unit_denominators=[SECOND])
37trace.add_gpu_counter_spec(
38    ts=2,
39    counter_id=32,
40    name="Fragment / Second",
41    description="Number of fragments per second",
42    unit_numerators=[PIXEL],
43    unit_denominators=[SECOND])
44trace.add_gpu_counter_spec(
45    ts=3,
46    counter_id=34,
47    name="Triangle Acceleration",
48    description="Number of triangles per ms-ms",
49    unit_numerators=[TRIANGLE],
50    unit_denominators=[MILLISECOND, MILLISECOND])
51
52# Add some counter value events.
53trace.add_gpu_counter(11, 31, 5)
54trace.add_gpu_counter(21, 31, 10)
55trace.add_gpu_counter(31, 31, 15)
56
57trace.add_gpu_counter(12, 32, 7)
58trace.add_gpu_counter(22, 32, 14)
59trace.add_gpu_counter(32, 32, 21)
60
61# Counter without a spec.
62trace.add_gpu_counter(13, 33, 8)
63trace.add_gpu_counter(23, 33, 16)
64trace.add_gpu_counter(33, 33, 25)
65
66trace.add_gpu_counter(14, 34, 0)
67trace.add_gpu_counter(24, 34, 9)
68trace.add_gpu_counter(34, 34, 7)
69
70sys.stdout.buffer.write(trace.trace.SerializeToString())
71