• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2018 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
20file_member = 0
21anon_member = 1
22swap_member = 2
23
24trace = synth_common.create_trace()
25trace.add_packet()
26trace.add_process(1, 0, 'init')
27trace.add_process(2, 1, 'system_server')
28trace.add_process(3, 1, 'com.google.android.calendar')
29trace.add_process(4, 1, 'com.google.android.deskclock')
30
31trace.add_ftrace_packet(cpu=0)
32# We are not yet aware of the OOM score. Will be ignored in the breakdowns.
33trace.add_rss_stat(100, 3, file_member, 10000)
34trace.add_rss_stat(100, 4, file_member, 10000)
35trace.add_rss_stat(100, 3, anon_member, 3000)
36trace.add_rss_stat(100, 4, anon_member, 6000)
37trace.add_rss_stat(100, 3, swap_member, 0)
38trace.add_rss_stat(100, 4, swap_member, 0)
39
40# Update the OOM scores.
41trace.add_oom_score_update(200, 0, 3)
42trace.add_oom_score_update(200, 900, 4)
43
44trace.add_rss_stat(200, 3, anon_member, 2000)
45trace.add_rss_stat(200, 4, anon_member, 4000)
46
47trace.add_rss_stat(250, 3, anon_member, 4000)
48trace.add_rss_stat(250, 4, anon_member, 8000)
49
50trace.add_oom_score_update(300, 910, 3)
51trace.add_oom_score_update(300, 0, 4)
52
53trace.add_rss_stat(300, 3, anon_member, 3000)
54trace.add_rss_stat(300, 4, anon_member, 6000)
55
56sys.stdout.buffer.write(trace.trace.SerializeToString())
57