Chromium Code Reviews| Index: tools/deep_memory_profiler/visualizer/template.py |
| diff --git a/tools/deep_memory_profiler/visualizer/template.py b/tools/deep_memory_profiler/visualizer/template.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..790adbd3fa20eaa773c1a87ab17c0c5380523234 |
| --- /dev/null |
| +++ b/tools/deep_memory_profiler/visualizer/template.py |
| @@ -0,0 +1,60 @@ |
| +#!/usr/bin/env python |
| +# |
| +# Copyright 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import commands |
| +import json |
| +import sys |
| +from string import Template |
| + |
|
Dai Mikurube (NOT FULLTIME)
2013/09/04 04:06:40
nit: better to have two empty lines between top-le
junjianx
2013/09/04 06:55:37
Done.
|
| +_TEMPLATE = """ |
| +<!DOCTYPE html> |
| +<meta charset="utf-8"> |
| +<link rel="stylesheet" href="index.css"> |
| +<link rel="stylesheet" href="third_party/jqTree/jqtree.css"> |
| + |
| +<script src="../../../third_party/flot/jquery.min.js"></script> |
| +<script src="../../../third_party/flot/jquery.flot.min.js"></script> |
| +<script src="../../../third_party/flot/jquery.flot.stack.min.js"></script> |
| +<script src="third_party/jqTree/tree.jquery.js"></script> |
| +<script src="utility.js"></script> |
| +<script src="profiler.js"></script> |
| +<script src="graph-view.js"></script> |
| +<script src="dropdown-view.js"></script> |
| +<script src="menu-view.js"></script> |
| +<script type="text/javascript"> |
| + $(function() { |
| + var data = $DATA; |
| + var profiler = new Profiler(data); |
| + var graphView = new GraphView(profiler); |
| + var dropdownView = new DropdownView(profiler); |
| + var menuView = new MenuView(profiler); |
| + |
| + profiler.reparse(); |
| +}); |
| +</script> |
| + |
| +<body> |
| + <h2>Deep Memory Profiler Visulaizer</h2> |
| + <div id="graph-div"></div> |
| + <div id="info-div"> |
| + <div id="subs-dropdown"></div> |
| + <div id="category-menu"></div> |
| + </div> |
| +</body> |
| +""" |
| + |
| +def main(argv): |
| + # Fill in the template of index.js. |
| + data = json.dumps(json.load(file(argv[1], 'r'))) |
|
Dai Mikurube (NOT FULLTIME)
2013/09/04 04:06:40
Do we need to json.load() and then json.dumps()? J
junjianx
2013/09/04 06:55:37
Done.
|
| + html = open('index.html', 'w') |
|
Dai Mikurube (NOT FULLTIME)
2013/09/04 04:06:40
1) Let's fix the directory to put the temporary ht
junjianx
2013/09/04 06:55:37
Done.
|
| + html.write(Template(_TEMPLATE).safe_substitute({ 'DATA': data })) |
| + html.close() |
| + # Open index page in chrome automatically if can. |
| + if commands.getoutput('type google-chrome') != 'google-chrome not found': |
|
Dai Mikurube (NOT FULLTIME)
2013/09/04 04:06:40
'type' works only for bash. Also, the user may not
junjianx
2013/09/04 06:55:37
Done.
|
| + commands.getstatusoutput('google-chrome index.html') |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv)) |