• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2# Copyright (C) 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#      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
18sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
19import synth_common
20
21# Since we do various time based conversions to build cycles/sec, ensure that
22# the timestamps look a bit realistic so they don't make those results look
23# weird.
24SEC = 1000000000
25
26trace = synth_common.create_trace()
27
28trace.add_system_info(arch='x86_64')
29trace.packet.system_info.hz = 1
30
31trace.add_packet(1)
32trace.add_cpu([100, 200])
33trace.add_cpu([1000, 2000])
34
35trace.add_packet(1 * SEC)
36trace.add_process_stats(pid=1, freqs={1: 1, 2: 1, 3: 1, 4: 1})
37trace.add_process_stats(pid=2, freqs={1: 1, 2: 1, 3: 1, 4: 1})
38
39trace.add_packet(2 * SEC)
40trace.add_process_stats(pid=1, freqs={1: 2, 3: 2})
41# Don't log anything for pid=2 thread, test that the packet at t=3 is based
42# against t=2 anyway.
43
44trace.add_packet(3 * SEC)
45trace.add_process_stats(pid=1, freqs={2: 11, 4: 11})
46trace.add_process_stats(pid=2, freqs={1: 11, 3: 11})
47
48print(trace.trace.SerializeToString())
49