##// END OF EJS Templates
contrib: make memory.py use absolute_import
Pulkit Goyal -
r28510:ade330de default
parent child Browse files
Show More
@@ -1,31 +1,32 b''
1 # memory.py - track memory usage
1 # memory.py - track memory usage
2 #
2 #
3 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''helper extension to measure memory usage
8 '''helper extension to measure memory usage
9
9
10 Reads current and peak memory usage from ``/proc/self/status`` and
10 Reads current and peak memory usage from ``/proc/self/status`` and
11 prints it to ``stderr`` on exit.
11 prints it to ``stderr`` on exit.
12 '''
12 '''
13
13
14 from __future__ import absolute_import
14 import atexit
15 import atexit
15
16
16 def memusage(ui):
17 def memusage(ui):
17 """Report memory usage of the current process."""
18 """Report memory usage of the current process."""
18 result = {'peak': 0, 'rss': 0}
19 result = {'peak': 0, 'rss': 0}
19 with open('/proc/self/status', 'r') as status:
20 with open('/proc/self/status', 'r') as status:
20 # This will only work on systems with a /proc file system
21 # This will only work on systems with a /proc file system
21 # (like Linux).
22 # (like Linux).
22 for line in status:
23 for line in status:
23 parts = line.split()
24 parts = line.split()
24 key = parts[0][2:-1].lower()
25 key = parts[0][2:-1].lower()
25 if key in result:
26 if key in result:
26 result[key] = int(parts[1])
27 result[key] = int(parts[1])
27 ui.write_err(", ".join(["%s: %.1f MiB" % (key, value / 1024.0)
28 ui.write_err(", ".join(["%s: %.1f MiB" % (key, value / 1024.0)
28 for key, value in result.iteritems()]) + "\n")
29 for key, value in result.iteritems()]) + "\n")
29
30
30 def extsetup(ui):
31 def extsetup(ui):
31 atexit.register(memusage, ui)
32 atexit.register(memusage, ui)
@@ -1,128 +1,127 b''
1 #require test-repo
1 #require test-repo
2
2
3 $ cd "$TESTDIR"/..
3 $ cd "$TESTDIR"/..
4
4
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
6 contrib/import-checker.py not using absolute_import
6 contrib/import-checker.py not using absolute_import
7 contrib/import-checker.py requires print_function
7 contrib/import-checker.py requires print_function
8 contrib/memory.py not using absolute_import
9 contrib/perf.py not using absolute_import
8 contrib/perf.py not using absolute_import
10 contrib/python-hook-examples.py not using absolute_import
9 contrib/python-hook-examples.py not using absolute_import
11 contrib/revsetbenchmarks.py not using absolute_import
10 contrib/revsetbenchmarks.py not using absolute_import
12 contrib/revsetbenchmarks.py requires print_function
11 contrib/revsetbenchmarks.py requires print_function
13 contrib/showstack.py not using absolute_import
12 contrib/showstack.py not using absolute_import
14 contrib/synthrepo.py not using absolute_import
13 contrib/synthrepo.py not using absolute_import
15 contrib/win32/hgwebdir_wsgi.py not using absolute_import
14 contrib/win32/hgwebdir_wsgi.py not using absolute_import
16 doc/check-seclevel.py not using absolute_import
15 doc/check-seclevel.py not using absolute_import
17 doc/gendoc.py not using absolute_import
16 doc/gendoc.py not using absolute_import
18 doc/hgmanpage.py not using absolute_import
17 doc/hgmanpage.py not using absolute_import
19 hgext/color.py not using absolute_import
18 hgext/color.py not using absolute_import
20 hgext/eol.py not using absolute_import
19 hgext/eol.py not using absolute_import
21 hgext/extdiff.py not using absolute_import
20 hgext/extdiff.py not using absolute_import
22 hgext/factotum.py not using absolute_import
21 hgext/factotum.py not using absolute_import
23 hgext/fetch.py not using absolute_import
22 hgext/fetch.py not using absolute_import
24 hgext/fsmonitor/pywatchman/__init__.py not using absolute_import
23 hgext/fsmonitor/pywatchman/__init__.py not using absolute_import
25 hgext/fsmonitor/pywatchman/__init__.py requires print_function
24 hgext/fsmonitor/pywatchman/__init__.py requires print_function
26 hgext/fsmonitor/pywatchman/capabilities.py not using absolute_import
25 hgext/fsmonitor/pywatchman/capabilities.py not using absolute_import
27 hgext/fsmonitor/pywatchman/pybser.py not using absolute_import
26 hgext/fsmonitor/pywatchman/pybser.py not using absolute_import
28 hgext/gpg.py not using absolute_import
27 hgext/gpg.py not using absolute_import
29 hgext/graphlog.py not using absolute_import
28 hgext/graphlog.py not using absolute_import
30 hgext/hgcia.py not using absolute_import
29 hgext/hgcia.py not using absolute_import
31 hgext/hgk.py not using absolute_import
30 hgext/hgk.py not using absolute_import
32 hgext/highlight/__init__.py not using absolute_import
31 hgext/highlight/__init__.py not using absolute_import
33 hgext/highlight/highlight.py not using absolute_import
32 hgext/highlight/highlight.py not using absolute_import
34 hgext/histedit.py not using absolute_import
33 hgext/histedit.py not using absolute_import
35 hgext/largefiles/__init__.py not using absolute_import
34 hgext/largefiles/__init__.py not using absolute_import
36 hgext/largefiles/basestore.py not using absolute_import
35 hgext/largefiles/basestore.py not using absolute_import
37 hgext/largefiles/lfcommands.py not using absolute_import
36 hgext/largefiles/lfcommands.py not using absolute_import
38 hgext/largefiles/lfutil.py not using absolute_import
37 hgext/largefiles/lfutil.py not using absolute_import
39 hgext/largefiles/localstore.py not using absolute_import
38 hgext/largefiles/localstore.py not using absolute_import
40 hgext/largefiles/overrides.py not using absolute_import
39 hgext/largefiles/overrides.py not using absolute_import
41 hgext/largefiles/proto.py not using absolute_import
40 hgext/largefiles/proto.py not using absolute_import
42 hgext/largefiles/remotestore.py not using absolute_import
41 hgext/largefiles/remotestore.py not using absolute_import
43 hgext/largefiles/reposetup.py not using absolute_import
42 hgext/largefiles/reposetup.py not using absolute_import
44 hgext/largefiles/uisetup.py not using absolute_import
43 hgext/largefiles/uisetup.py not using absolute_import
45 hgext/largefiles/wirestore.py not using absolute_import
44 hgext/largefiles/wirestore.py not using absolute_import
46 hgext/mq.py not using absolute_import
45 hgext/mq.py not using absolute_import
47 hgext/rebase.py not using absolute_import
46 hgext/rebase.py not using absolute_import
48 hgext/share.py not using absolute_import
47 hgext/share.py not using absolute_import
49 hgext/win32text.py not using absolute_import
48 hgext/win32text.py not using absolute_import
50 i18n/check-translation.py not using absolute_import
49 i18n/check-translation.py not using absolute_import
51 i18n/polib.py not using absolute_import
50 i18n/polib.py not using absolute_import
52 setup.py not using absolute_import
51 setup.py not using absolute_import
53 tests/filterpyflakes.py requires print_function
52 tests/filterpyflakes.py requires print_function
54 tests/generate-working-copy-states.py requires print_function
53 tests/generate-working-copy-states.py requires print_function
55 tests/get-with-headers.py requires print_function
54 tests/get-with-headers.py requires print_function
56 tests/heredoctest.py requires print_function
55 tests/heredoctest.py requires print_function
57 tests/hypothesishelpers.py not using absolute_import
56 tests/hypothesishelpers.py not using absolute_import
58 tests/hypothesishelpers.py requires print_function
57 tests/hypothesishelpers.py requires print_function
59 tests/killdaemons.py not using absolute_import
58 tests/killdaemons.py not using absolute_import
60 tests/md5sum.py not using absolute_import
59 tests/md5sum.py not using absolute_import
61 tests/mockblackbox.py not using absolute_import
60 tests/mockblackbox.py not using absolute_import
62 tests/printenv.py not using absolute_import
61 tests/printenv.py not using absolute_import
63 tests/readlink.py not using absolute_import
62 tests/readlink.py not using absolute_import
64 tests/readlink.py requires print_function
63 tests/readlink.py requires print_function
65 tests/revlog-formatv0.py not using absolute_import
64 tests/revlog-formatv0.py not using absolute_import
66 tests/run-tests.py not using absolute_import
65 tests/run-tests.py not using absolute_import
67 tests/seq.py not using absolute_import
66 tests/seq.py not using absolute_import
68 tests/seq.py requires print_function
67 tests/seq.py requires print_function
69 tests/silenttestrunner.py not using absolute_import
68 tests/silenttestrunner.py not using absolute_import
70 tests/silenttestrunner.py requires print_function
69 tests/silenttestrunner.py requires print_function
71 tests/sitecustomize.py not using absolute_import
70 tests/sitecustomize.py not using absolute_import
72 tests/svn-safe-append.py not using absolute_import
71 tests/svn-safe-append.py not using absolute_import
73 tests/svnxml.py not using absolute_import
72 tests/svnxml.py not using absolute_import
74 tests/test-ancestor.py requires print_function
73 tests/test-ancestor.py requires print_function
75 tests/test-atomictempfile.py not using absolute_import
74 tests/test-atomictempfile.py not using absolute_import
76 tests/test-batching.py not using absolute_import
75 tests/test-batching.py not using absolute_import
77 tests/test-batching.py requires print_function
76 tests/test-batching.py requires print_function
78 tests/test-bdiff.py not using absolute_import
77 tests/test-bdiff.py not using absolute_import
79 tests/test-bdiff.py requires print_function
78 tests/test-bdiff.py requires print_function
80 tests/test-context.py not using absolute_import
79 tests/test-context.py not using absolute_import
81 tests/test-context.py requires print_function
80 tests/test-context.py requires print_function
82 tests/test-demandimport.py not using absolute_import
81 tests/test-demandimport.py not using absolute_import
83 tests/test-demandimport.py requires print_function
82 tests/test-demandimport.py requires print_function
84 tests/test-doctest.py not using absolute_import
83 tests/test-doctest.py not using absolute_import
85 tests/test-duplicateoptions.py not using absolute_import
84 tests/test-duplicateoptions.py not using absolute_import
86 tests/test-duplicateoptions.py requires print_function
85 tests/test-duplicateoptions.py requires print_function
87 tests/test-filecache.py not using absolute_import
86 tests/test-filecache.py not using absolute_import
88 tests/test-filecache.py requires print_function
87 tests/test-filecache.py requires print_function
89 tests/test-filelog.py not using absolute_import
88 tests/test-filelog.py not using absolute_import
90 tests/test-filelog.py requires print_function
89 tests/test-filelog.py requires print_function
91 tests/test-hg-parseurl.py not using absolute_import
90 tests/test-hg-parseurl.py not using absolute_import
92 tests/test-hg-parseurl.py requires print_function
91 tests/test-hg-parseurl.py requires print_function
93 tests/test-hgweb-auth.py not using absolute_import
92 tests/test-hgweb-auth.py not using absolute_import
94 tests/test-hgweb-auth.py requires print_function
93 tests/test-hgweb-auth.py requires print_function
95 tests/test-hgwebdir-paths.py not using absolute_import
94 tests/test-hgwebdir-paths.py not using absolute_import
96 tests/test-hybridencode.py not using absolute_import
95 tests/test-hybridencode.py not using absolute_import
97 tests/test-hybridencode.py requires print_function
96 tests/test-hybridencode.py requires print_function
98 tests/test-lrucachedict.py not using absolute_import
97 tests/test-lrucachedict.py not using absolute_import
99 tests/test-lrucachedict.py requires print_function
98 tests/test-lrucachedict.py requires print_function
100 tests/test-manifest.py not using absolute_import
99 tests/test-manifest.py not using absolute_import
101 tests/test-minirst.py not using absolute_import
100 tests/test-minirst.py not using absolute_import
102 tests/test-minirst.py requires print_function
101 tests/test-minirst.py requires print_function
103 tests/test-parseindex2.py not using absolute_import
102 tests/test-parseindex2.py not using absolute_import
104 tests/test-parseindex2.py requires print_function
103 tests/test-parseindex2.py requires print_function
105 tests/test-pathencode.py not using absolute_import
104 tests/test-pathencode.py not using absolute_import
106 tests/test-pathencode.py requires print_function
105 tests/test-pathencode.py requires print_function
107 tests/test-propertycache.py not using absolute_import
106 tests/test-propertycache.py not using absolute_import
108 tests/test-propertycache.py requires print_function
107 tests/test-propertycache.py requires print_function
109 tests/test-revlog-ancestry.py not using absolute_import
108 tests/test-revlog-ancestry.py not using absolute_import
110 tests/test-revlog-ancestry.py requires print_function
109 tests/test-revlog-ancestry.py requires print_function
111 tests/test-run-tests.py not using absolute_import
110 tests/test-run-tests.py not using absolute_import
112 tests/test-simplemerge.py not using absolute_import
111 tests/test-simplemerge.py not using absolute_import
113 tests/test-status-inprocess.py not using absolute_import
112 tests/test-status-inprocess.py not using absolute_import
114 tests/test-status-inprocess.py requires print_function
113 tests/test-status-inprocess.py requires print_function
115 tests/test-symlink-os-yes-fs-no.py not using absolute_import
114 tests/test-symlink-os-yes-fs-no.py not using absolute_import
116 tests/test-trusted.py not using absolute_import
115 tests/test-trusted.py not using absolute_import
117 tests/test-trusted.py requires print_function
116 tests/test-trusted.py requires print_function
118 tests/test-ui-color.py not using absolute_import
117 tests/test-ui-color.py not using absolute_import
119 tests/test-ui-color.py requires print_function
118 tests/test-ui-color.py requires print_function
120 tests/test-ui-config.py not using absolute_import
119 tests/test-ui-config.py not using absolute_import
121 tests/test-ui-config.py requires print_function
120 tests/test-ui-config.py requires print_function
122 tests/test-ui-verbosity.py not using absolute_import
121 tests/test-ui-verbosity.py not using absolute_import
123 tests/test-ui-verbosity.py requires print_function
122 tests/test-ui-verbosity.py requires print_function
124 tests/test-url.py not using absolute_import
123 tests/test-url.py not using absolute_import
125 tests/test-url.py requires print_function
124 tests/test-url.py requires print_function
126 tests/test-walkrepo.py requires print_function
125 tests/test-walkrepo.py requires print_function
127 tests/test-wireproto.py requires print_function
126 tests/test-wireproto.py requires print_function
128 tests/tinyproxy.py requires print_function
127 tests/tinyproxy.py requires print_function
General Comments 0
You need to be logged in to leave comments. Login now