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

Side by Side Diff: tools/binary_size/helpers.py

Issue 2724253002: V1 of //tools/binary_size rewrite (Closed)
Patch Set: Add repl to query.py Created 3 years, 9 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
OLDNEW
(Empty)
1 # Copyright 2017 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 """Utility methods."""
6
7 import distutils.spawn
8 import logging
9 import os
10 import platform
11 import resource
12 import sys
13
14
15 SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
16
17
18 def AddCommonOptions(parser):
19 parser.add_argument('--no-pypy', action='store_true',
20 help='Do not automatically switch to pypy when available')
21 parser.add_argument('-v',
22 '--verbose',
23 default=0,
24 action='count',
25 help='Verbose level (multiple times for more)')
26
27
28 def HandleCommonOptions(args):
29 logging.basicConfig(level=logging.WARNING - args.verbose * 10,
30 format='%(levelname).1s %(relativeCreated)6d %(message)s')
31
32 if not args.no_pypy and platform.python_implementation() == 'CPython':
33 # Switch to pypy if it's available.
34 pypy_path = distutils.spawn.find_executable('pypy')
35 if pypy_path:
36 logging.debug('Switching to pypy.')
37 os.execv(pypy_path, [pypy_path] + sys.argv)
38 # NOTE! Running with python: 6s. Running with pypy: 3s
39 logging.warning('This script will run more than 2x as fast if you install '
estevenson 2017/03/16 19:49:18 FYI I hit this path when running the script (I thi
agrieve 2017/03/20 19:58:08 No, I had to install it manually (sudo apt-get ins
40 'pypy.')
41
42 def GetPeakRamUsage():
43 peak_ram_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
44 peak_ram_usage += resource.getrusage(resource.RUSAGE_CHILDREN).ru_maxrss
45 return peak_ram_usage / 1024
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698