| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import collections | 7 import collections |
| 8 import json | 8 import json |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 count = 0 | 227 count = 0 |
| 228 while not should_quit.is_set(): | 228 while not should_quit.is_set(): |
| 229 print >>sys.stderr, 'Collecting ', count | 229 print >>sys.stderr, 'Collecting ', count |
| 230 _CollectStats(count) | 230 _CollectStats(count) |
| 231 count += 1 | 231 count += 1 |
| 232 should_quit.wait(interval) | 232 should_quit.wait(interval) |
| 233 | 233 |
| 234 t = threading.Thread(target=_Loop) | 234 t = threading.Thread(target=_Loop) |
| 235 | 235 |
| 236 | 236 |
| 237 print >>sys.stderr, 'Press enter to stop' | 237 print >>sys.stderr, 'Press enter or CTRL+C to stop' |
| 238 t.start() | 238 t.start() |
| 239 try: | 239 try: |
| 240 _ = raw_input() | 240 _ = raw_input() |
| 241 except KeyboardInterrupt: |
| 242 pass |
| 241 finally: | 243 finally: |
| 242 should_quit.set() | 244 should_quit.set() |
| 243 | 245 |
| 244 t.join() | 246 t.join() |
| 245 | 247 |
| 246 _GenerateGraph() | 248 _GenerateGraph() |
| 247 | 249 |
| 248 | 250 |
| 249 def main(argv): | 251 def main(argv): |
| 250 parser = optparse.OptionParser(usage='Usage: %prog [options]', | 252 parser = optparse.OptionParser(usage='Usage: %prog [options]', |
| (...skipping 12 matching lines...) Expand all Loading... |
| 263 type='int', | 265 type='int', |
| 264 help='Interval in seconds for manual collections.') | 266 help='Interval in seconds for manual collections.') |
| 265 options, args = parser.parse_args(argv) | 267 options, args = parser.parse_args(argv) |
| 266 if options.manual_graph: | 268 if options.manual_graph: |
| 267 return _RunManualGraph(options.package, options.interval) | 269 return _RunManualGraph(options.package, options.interval) |
| 268 _DumpCSV(_CollectMemoryStats(sys.stdin, [value for (key, value) in _ENTRIES])) | 270 _DumpCSV(_CollectMemoryStats(sys.stdin, [value for (key, value) in _ENTRIES])) |
| 269 | 271 |
| 270 | 272 |
| 271 if __name__ == '__main__': | 273 if __name__ == '__main__': |
| 272 main(sys.argv) | 274 main(sys.argv) |
| OLD | NEW |