Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de>
Branch: 
Changeset: r96676:9cfdc2c91a37
Date: 2019-05-25 11:27 +0200
http://bitbucket.org/pypy/pypy/changeset/9cfdc2c91a37/

Log:    merge fix-vmprof-memory-tracking

diff --git a/pypy/module/_vmprof/interp_vmprof.py 
b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -60,11 +60,6 @@
     'interval' is a float representing the sampling interval, in seconds.
     Must be smaller than 1.0
     """
-    w_modules = space.sys.get('modules')
-    #if space.contains_w(w_modules, space.newtext('_continuation')):
-    #    space.warn(space.newtext("Using _continuation/greenlet/stacklet 
together "
-    #                             "with vmprof will crash"),
-    #               space.w_RuntimeWarning)
     try:
         rvmprof.enable(fileno, period, memory, native, real_time)
     except rvmprof.VMProfError as e:
diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py
--- a/rpython/rlib/rvmprof/rvmprof.py
+++ b/rpython/rlib/rvmprof/rvmprof.py
@@ -143,7 +143,7 @@
             native = 0 # force disabled on Windows
         lines = 0 # not supported on PyPy currently
 
-        p_error = self.cintf.vmprof_init(fileno, interval, lines, memory, 
"pypy", native, real_time)
+        p_error = self.cintf.vmprof_init(fileno, interval, memory, lines, 
"pypy", native, real_time)
         if p_error:
             raise VMProfError(rffi.charp2str(p_error))
 
diff --git a/rpython/rlib/rvmprof/test/test_rvmprof.py 
b/rpython/rlib/rvmprof/test/test_rvmprof.py
--- a/rpython/rlib/rvmprof/test/test_rvmprof.py
+++ b/rpython/rlib/rvmprof/test/test_rvmprof.py
@@ -98,12 +98,12 @@
         self.tmpfilename = str(self.tmpfile)
         super(RVMProfSamplingTest, self).init()
 
-    ENTRY_POINT_ARGS = (int, float)
-    def entry_point(self, value, delta_t):
+    ENTRY_POINT_ARGS = (int, float, int)
+    def entry_point(self, value, delta_t, memory=0):
         code = self.MyCode('py:code:52:test_enable')
         rvmprof.register_code(code, self.MyCode.get_name)
         fd = os.open(self.tmpfilename, os.O_WRONLY | os.O_CREAT, 0666)
-        rvmprof.enable(fd, self.SAMPLING_INTERVAL)
+        rvmprof.enable(fd, self.SAMPLING_INTERVAL, memory=memory)
         start = time.time()
         res = 0
         while time.time() < start+delta_t:
@@ -128,17 +128,25 @@
 
     def test(self):
         from vmprof import read_profile
-        assert self.entry_point(10**4, 0.1) == 99990000
+        assert self.entry_point(10**4, 0.1, 0) == 99990000
         assert self.tmpfile.check()
         self.tmpfile.remove()
         #
-        assert self.rpy_entry_point(10**4, 0.5) == 99990000
+        assert self.rpy_entry_point(10**4, 0.5, 0) == 99990000
         assert self.tmpfile.check()
         prof = read_profile(self.tmpfilename)
         tree = prof.get_tree()
         assert tree.name == 'py:code:52:test_enable'
         assert self.approx_equal(tree.count, 0.5/self.SAMPLING_INTERVAL)
 
+    def test_mem(self):
+        from vmprof import read_profile
+        assert self.rpy_entry_point(10**4, 0.5, 1) == 99990000
+        assert self.tmpfile.check()
+        prof = read_profile(self.tmpfilename)
+        assert prof.profile_memory
+        assert all(p[-1] > 0 for p in prof.profiles)
+
 
 class TestNative(RVMProfSamplingTest):
 
@@ -177,7 +185,7 @@
     def test(self):
         from vmprof import read_profile
         # from vmprof.show import PrettyPrinter
-        assert self.rpy_entry_point(3, 0.5) == 42000
+        assert self.rpy_entry_point(3, 0.5, 0) == 42000
         assert self.tmpfile.check()
 
         prof = read_profile(self.tmpfilename)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to