how to profile PyPy with vmprof?

854 views Asked by At

I read the vmprof doc in https://vmprof.readthedocs.io/en/latest/vmprof.html And I try to to prof pypy, with the cmd:

 pypy -m vmprof --web  hello.py

Then i return that:

/usr/bin/pypy: No module named vmprof

I Try

pip install vmprof 

then

 pypy -m vmprof --web  hello.py

But it doesn't work yet! I am totally confused, can somebody tell me what should i do??? where's the right way?

------- the next day update ---------- aha, now I find the way out!

clone this git repo

https://github.com/vmprof/vmprof-python.git

and that

cd vmprof
cd vmprof-python/
pypy setup.py install

Now you find your pypy have the module vmprof now !

but i meet a new problem, somebody knows how to solve it ?

xxx@yyy:~$  pypy -m vmprof  hello.py

Traceback (most recent call last):
  File "/usr/lib/pypy/lib-python/2.7/runpy.py", line 176, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/pypy/lib-python/2.7/runpy.py", line 73, in _run_code
    exec code in run_globals
  File "/usr/local/lib/pypy2.7/dist-packages/vmprof-0.4.15-py2.7.egg/vmprof/__main__.py", line 75, in <module>
    main()
  File "/usr/local/lib/pypy2.7/dist-packages/vmprof-0.4.15-py2.7.egg/vmprof/__main__.py", line 53, in main
    args.lines, native=native)
  File "/usr/local/lib/pypy2.7/dist-packages/vmprof-0.4.15-py2.7.egg/vmprof/__init__.py", line 72, in enable
    _vmprof.enable(fileno, period, memory, lines, native, real_time)
VMProfError: Invalid argument

I am using a wsl(Windows subsystem for linux), and version is

xxx@yyy:~$  cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

my pypy

xxx@yyy:~$ pypy
Python 2.7.13 (5.10.0+dfsg-3build2, Feb 06 2018, 18:37:50)
[PyPy 5.10.0 with GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>>
1

There are 1 answers

1
qwr On

Are you sure your pip corresponds to pypy and not vanilla python? Try

pypy -m pip install vmprof