Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: build/android/chrome_profiler/postprocessor_unittest.py

Issue 293193002: adb_profile_chrome: Add perf profiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented trace merging. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from chrome_profiler import postprocessor
6
7 import json
8 import tempfile
9 import unittest
10
11
12 class PostprocessorTest(unittest.TestCase):
13 def testJsonTraceMerging(self):
14 t1 = {'traceEvents': [{'ts': 123, 'ph': 'b'}]}
15 t2 = {'traceEvents': [], 'stackFrames': ['blah']}
16
17 with tempfile.NamedTemporaryFile(delete=False) as f1:
18 with tempfile.NamedTemporaryFile(delete=False) as f2:
bulach 2014/06/04 10:34:12 why delete=False? the with would only close them a
Sami 2014/06/04 15:16:59 Both of these files get deleted during merging, an
19 f1.write(json.dumps(t1))
20 f2.write(json.dumps(t2))
21 f1.flush()
22 f2.flush()
23
24 with tempfile.NamedTemporaryFile() as output:
25 postprocessor.PackageTraces([f1.name, f2.name],
26 output.name,
27 compress=False,
28 write_json=True)
29 with open(output.name) as output:
30 output = json.load(output)
31 self.assertEquals(output['traceEvents'], t1['traceEvents'])
32 self.assertEquals(output['stackFrames'], t2['stackFrames'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698