1
# ***** BEGIN LICENSE BLOCK *****
2
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
# The contents of this file are subject to the Mozilla Public License Version
5
# 1.1 (the "License"); you may not use this file except in compliance with
6
# the License. You may obtain a copy of the License at
7
# http://www.mozilla.org/MPL/
9
# Software distributed under the License is distributed on an "AS IS" basis,
10
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
# for the specific language governing rights and limitations under the
14
# The Original Code is cl.py: a python wrapper for cl to automatically generate
15
# dependency information.
17
# The Initial Developer of the Original Code is
19
# Portions created by the Initial Developer are Copyright (C) 2010
20
# the Initial Developer. All Rights Reserved.
23
# Ted Mielczarek <ted@mielczarek.org>
25
# Alternatively, the contents of this file may be used under the terms of
26
# either the GNU General Public License Version 2 or later (the "GPL"), or
27
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
# in which case the provisions of the GPL or the LGPL are applicable instead
29
# of those above. If you wish to allow use of your version of this file only
30
# under the terms of either the GPL or the LGPL, and not to allow others to
31
# use your version of this file under the terms of the MPL, indicate your
32
# decision by deleting the provisions above and replace them with the notice
33
# and other provisions required by the GPL or the LGPL. If you do not delete
34
# the provisions above, a recipient may use your version of this file under
35
# the terms of any one of the MPL, the GPL or the LGPL.
37
# ***** END LICENSE BLOCK *****
39
from __future__ import with_statement
40
import os, platform, subprocess, sys, threading, time
41
from win32 import procmem
43
def measure_vsize_threadfunc(proc, output_file):
45
Measure the virtual memory usage of |proc| at regular intervals
46
until it exits, then print the maximum value and write it to
50
while proc.returncode is None:
51
maxvsize, vsize = procmem.get_vmsize(proc._handle)
53
print "linker max virtual size: %d" % maxvsize
54
with open(output_file, "w") as f:
55
f.write("%d\n" % maxvsize)
57
def measure_link_vsize(output_file, args):
59
Execute |args|, and measure the maximum virtual memory usage of the process,
60
printing it to stdout when finished.
62
proc = subprocess.Popen(args)
63
t = threading.Thread(target=measure_vsize_threadfunc,
64
args=(proc, output_file))
66
# Wait for the linker to finish.
67
exitcode = proc.wait()
68
# ...and then wait for the background thread to finish.
72
if __name__ == "__main__":
73
if platform.system() != "Windows":
74
print >>sys.stderr, "link.py is only for use on Windows!"
77
print >>sys.stderr, "Usage: link.py <output filename> <commandline>"
79
sys.exit(measure_link_vsize(sys.argv[1], sys.argv[2:]))
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
from __future__ import with_statement
6
import os, subprocess, sys, threading, time
7
from win32 import procmem
9
def measure_vsize_threadfunc(proc, output_file):
11
Measure the virtual memory usage of |proc| at regular intervals
12
until it exits, then print the maximum value and write it to
16
while proc.returncode is None:
17
maxvsize, vsize = procmem.get_vmsize(proc._handle)
19
print "TinderboxPrint: linker max vsize: %d" % maxvsize
20
with open(output_file, "w") as f:
21
f.write("%d\n" % maxvsize)
23
def measure_link_vsize(output_file, args):
25
Execute |args|, and measure the maximum virtual memory usage of the process,
26
printing it to stdout when finished.
28
proc = subprocess.Popen(args)
29
t = threading.Thread(target=measure_vsize_threadfunc,
30
args=(proc, output_file))
32
# Wait for the linker to finish.
33
exitcode = proc.wait()
34
# ...and then wait for the background thread to finish.
38
if __name__ == "__main__":
39
if sys.platform != "win32":
40
print >>sys.stderr, "link.py is only for use on Windows!"
43
print >>sys.stderr, "Usage: link.py <output filename> <commandline>"
45
sys.exit(measure_link_vsize(sys.argv[1], sys.argv[2:]))