Giter Site home page Giter Site logo

vmprof / vmprof-python Goto Github PK

View Code? Open in Web Editor NEW
432.0 13.0 54.0 3.15 MB

vmprof - a statistical program profiler

Home Page: http://vmprof.com

License: Other

C 66.04% C++ 0.97% Python 24.22% Shell 2.62% Makefile 4.20% M4 1.89% Awk 0.04%
profiler python python-3 vmprof statistics profile c native pypy

vmprof-python's Introduction

VMProf Python package

Build Status on TravisCI Build Status on TeamCity Read The Docs Build Status on AppVeyor

Head over to https://vmprof.readthedocs.org for more info!

Installation

pip install vmprof
python -m vmprof <your program> <your program args>

Our build system ships wheels to PyPI (Linux, Mac OS X). If you build from source you need to install CPython development headers and libunwind headers (on Linux only). On Windows this means you need Microsoft Visual C++ Compiler for your Python version.

Development

Setting up development can be done using the following commands:

$ virtualenv -p /usr/bin/python3 vmprof3
$ source vmprof3/bin/activate
$ python setup.py develop

You need to install python development packages. In case of e.g. Debian or Ubuntu the package you need is python3-dev and libunwind-dev. Now it is time to write a test and implement your feature. If you want your changes to affect vmprof.com, head over to https://github.com/vmprof/vmprof-server and follow the setup instructions.

Consult our section for development at https://vmprof.readthedocs.org for more information.

vmprofshow

vmprofshow is a command line tool that comes with VMProf. It can read profile files and produce a formatted output.

Here is an example of how to use vmprofshow:

Run that smallish program which burns CPU cycles (with vmprof enabled):

$ pypy vmprof/test/cpuburn.py # you can find cpuburn.py in the vmprof-python repo

This will produce a profile file vmprof_cpuburn.dat. Now display the profile using vmprofshow. vmprofshow has multiple modes of showing data. We'll start with the tree-based mode.

Tree-based output

$ vmprofshow vmprof_cpuburn.dat tree

You will see a (colored) output:

$ vmprofshow vmprof_cpuburn.dat tree
100.0%  <module>  100.0%  tests/cpuburn.py:1
100.0% .. test  100.0%  tests/cpuburn.py:35
100.0% .... burn  100.0%  tests/cpuburn.py:26
 99.2% ...... _iterate  99.2%  tests/cpuburn.py:19
 97.7% ........ _iterate  98.5%  tests/cpuburn.py:19
 22.9% .......... _next_rand  23.5%  tests/cpuburn.py:14
 22.9% ............ JIT code  100.0%  0x7fa7dba57a10
 74.7% .......... JIT code  76.4%  0x7fa7dba57a10
  0.1% .......... JIT code  0.1%  0x7fa7dba583b0
  0.5% ........ _next_rand  0.5%  tests/cpuburn.py:14
  0.0% ........ JIT code  0.0%  0x7fa7dba583b0

There is also an option --html to emit the same information as HTML to view in a browser. In this case, the tree branches can be interactively expanded and collapsed.

Line-based output

vmprof supports line profiling mode, which enables collecting and showing the statistics for separate lines inside functions.

To enable collection of lines statistics add --lines argument to vmprof:

$ python -m vmprof --lines -o <output-file> <your program> <your program args>

Or pass lines=True argument to vmprof.enable function, when calling vmprof from code.

To see line statistics for all functions use the lines mode of vmprofshow:

$ vmprofshow <output-file> lines

To see line statistics for a specific function use the --filter argument with the function name:

$ vmprofshow <output-file> lines --filter <function-name>

You will see the result:

$ vmprofshow vmprof_cpuburn.dat lines --filter _next_rand
Total hits: 1170 s
File: tests/cpuburn.py
Function: _next_rand at line 14

Line #     Hits   % Hits  Line Contents
=======================================
    14       38      3.2      def _next_rand(self):
    15                            # http://rosettacode.org/wiki/Linear_congruential_generator
    16      835     71.4          self._rand = (1103515245 * self._rand + 12345) & 0x7fffffff
    17      297     25.4          return self._rand

"Flattened" output

vmprofshow also has a flat mode.

While the tree-based and line-based output styles for vmprofshow give a good view of where time is spent when viewed from the 'root' of the call graph, sometimes it is desirable to get a view from 'leaves' instead. This is particularly helpful when functions exist that get called from multiple places, where each invocation does not consume much time, but all invocations taken together do amount to a substantial cost.

$ vmprofshow vmprof_cpuburn.dat flat                                                                                                                                                                                                                                                                                                                                                                                   andreask_work@dunkel 15:24
    28.895% - _PyFunction_Vectorcall:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/call.c:389
    18.076% - _iterate:cpuburn.py:20
    17.298% - _next_rand:cpuburn.py:15
     5.863% - <native symbol 0x563a5f4eea51>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3707
     5.831% - PyObject_SetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1031
     4.924% - <native symbol 0x563a5f43fc01>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:787
     4.762% - PyObject_GetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:931
     4.373% - <native symbol 0x563a5f457eb1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:1071
     3.758% - PyNumber_Add:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:957
     3.110% - <native symbol 0x563a5f47c291>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:4848
     1.587% - PyNumber_Multiply:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:988
     1.166% - _PyObject_GetMethod:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1139
     0.356% - <native symbol 0x563a5f4ed8f1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3432
     0.000% - <native symbol 0x7f0dce8cca80>:-:0
     0.000% - test:cpuburn.py:36
     0.000% - burn:cpuburn.py:27

Sometimes it may be desirable to exclude "native" functions:

$ vmprofshow vmprof_cpuburn.dat flat --no-native                                                                                                                                                                                                                                                                                                                                                                       andreask_work@dunkel 15:27
    53.191% - _next_rand:cpuburn.py:15
    46.809% - _iterate:cpuburn.py:20
     0.000% - test:cpuburn.py:36
     0.000% - burn:cpuburn.py:27

Note that the output represents the time spent in each function, exclusive of functions called. (In --no-native mode, native-code callees remain included in the total.)

Sometimes it may also be desirable to get timings inclusive of called functions:

$ vmprofshow vmprof_cpuburn.dat flat --include-callees                                                                                                                                                                                                                                                                                                                                                                 andreask_work@dunkel 15:31
   100.000% - <native symbol 0x7f0dce8cca80>:-:0
   100.000% - test:cpuburn.py:36
   100.000% - burn:cpuburn.py:27
   100.000% - _iterate:cpuburn.py:20
    53.191% - _next_rand:cpuburn.py:15
    28.895% - _PyFunction_Vectorcall:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/call.c:389
     7.807% - PyNumber_Multiply:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:988
     7.483% - <native symbol 0x563a5f457eb1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:1071
     6.220% - <native symbol 0x563a5f4eea51>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3707
     5.831% - PyObject_SetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1031
     4.924% - <native symbol 0x563a5f43fc01>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:787
     4.762% - PyObject_GetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:931
     3.758% - PyNumber_Add:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:957
     3.110% - <native symbol 0x563a5f47c291>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:4848
     1.166% - _PyObject_GetMethod:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1139
     0.356% - <native symbol 0x563a5f4ed8f1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3432

This view is quite similar to the "tree" view, minus the nesting.

vmprof-python's People

Contributors

antocuni avatar apatrascu avatar arigo avatar bawr avatar borman avatar cfbolz avatar cskorpion avatar dianpopa avatar dragonsa avatar fijal avatar gchiam avatar gsnedders avatar inducer avatar jkogut avatar jogo avatar johan-olsson-by avatar jonashaag avatar kojoley avatar matthiasdiener avatar mattip avatar methane avatar moylop260 avatar myint avatar palpant-dbx avatar planrich avatar rlamy avatar timpalpant avatar trofimander avatar xando avatar ympro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vmprof-python's Issues

PyPy/OS X: reader.py can't parse `vmmap` output

On OS X with a self-translated PyPy 2.6.1, _vmprof uses the vmmap executable to produce output that becomes part of the profile data. This output has header lines and lines of a different format than expected that cause vmprof.reader:read_ranges to fail with ValueError and IndexError. For example:

  File "//site-packages/vmprof/profiler.py", line 31, in read_profile
    period, profiles, virtual_symbols, libs, interp_name = read_prof(prof)
  File "//site-packages/vmprof/reader.py", line 173, in read_prof
    symmap = read_ranges(fileobj.read())
  File "//site-packages/vmprof/reader.py", line 90, in read_ranges
    start, end = parts[0].split('-')
ValueError: expected length 2, got 1

Example output from a profile log: (This is with XCode 6.1, but I get the same results with XCode 7)

Pro
cess:         pypy [10569]
Path:            //bin/pypy
Load Address:    0x107e6f000
Identifier:      pypy
Version:         ???
Code Type:       X86-64
Parent Process:  bash [41008]

Date/Time:       2015-09-22 14:49:01.181 -0500
Launch Time:     2015-09-22 14:48:39.313 -0500
OS Version:      Mac OS X 10.11 (15A282b)
Report Version:  7
Analysis Tool:   /usr/bin/vmmap
----

Virtual Memory Map of process 10569 (python)
Output report format:  2.4  -- 64-bit process
VM page size:  4096 bytes

==== Non-writable regions for process 10569
REGION TYPE                      START - END             [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
__TEXT                 0000000107e6f000-0000000107e70000 [    4K] r-x/rwx SM=COW  /Users/jmadden/Projects/VirtualEnvs/relstoragepypy/bin/pypy
__LINKEDIT             0000000107e71000-0000000107e72000 [    4K] r--/rwx SM=COW  /Users/jmadden/Projects/VirtualEnvs/relstoragepypy/bin/pypy
MALLOC metadata        0000000107e73000-0000000107e74000 [    4K] r--/rwx SM=COW
MALLOC metadata        0000000107e75000-0000000107e76000 [    4K] r--/rwx SM=COW
__TEXT                 0000000107e77000-0000000107ec0000 [  292K] r-x/rwx SM=COW  /opt/local/lib/libssl.1.0.0.dylib
__LINKEDIT             0000000107ecb000-0000000107edd000 [   72K] r--/rwx SM=COW  /opt/local/lib/libssl.1.0.0.dylib
shared memory          0000000107edd000-0000000107ede000 [    4K] r--/rw- SM=SHM
__TEXT                 0000000107ede000-0000000107edf000 [    4K] r-x/rwx SM=COW  /Users/jmadden/bin/pypy-2.6.1-osx64/lib_pypy/_pwdgrp_cffi.pypy-26.so
__LINKEDIT             0000000107ee0000-0000000107ee1000 [    4K] r--/rwx SM=COW  /Users/jmadden/bin/pypy-2.6.1-osx64/lib_pypy/_pwdgrp_cffi.pypy-26.so
__TEXT                 0000000107ee1000-0000000107eeb000 [   40K] r-x/rwx SM=COW  /opt/local/lib/libintl.8.dylib
__LINKEDIT             0000000107eec000-0000000107eef000 [   12K] r--/rwx SM=COW  /opt/local/lib/libintl.8.dylib
__TEXT                 0000000107ef0000-0000000107ef1000 [    4K] r-x/rwx SM=COW  ...ughtPlatform/nti.dataserver-buildout/sources/persistent/persistent/__pycache__/_cffi__g4bdcd39cx2c90fb3d.pypy-26.so
__LINKEDIT             0000000107ef2000-0000000107ef3000 [    4K] r--/rwx SM=COW  ...ughtPlatform/nti.dataserver-buildout/sources/persistent/persistent/__pycache__/_cffi__g4bdcd39cx2c90fb3d.pypy-26.so
__TEXT                 0000000107ef3000-00000001092ba000 [ 19.8M] r-x/rwx SM=COW  /Users/jmadden/Projects/pypy-2.6.1-src/pypy/goal/libpypy-c.dylib
__LINKEDIT             000000010a56c000-000000010b973000 [ 20.0M] r--/rwx SM=COW  /Users/jmadden/Projects/pypy-2.6.1-src/pypy/goal/libpypy-c.dylib

I can hack around it by adding some except clauses, like follows, but that's probably not the right solution. I'm guessing the parser was designed for FreeBSD's output, based on the comments in vmprof_main.h, but I don't have an example of that handy.

        if procstat:
            start, end = parts[1], parts[2]
        else:
            try:
                start, end = parts[1].split('-')
            except (ValueError, IndexError):
                #print('skipping', parts)
                continue
        try:
            start = int(start, 16)
            end = int(end, 16)
        except ValueError:
            #print("Non int", parts)
            continue

The above hack lets vmprofshow continue running, but it eventually fails with an EmptyProfileFile exception. I'm not yet sure if that's related or a different issue:

WARNING: cannot read symbols for ...ughtPlatform/nti.dataserver-buildout/sources/persistent/persistent/__pycache__/_cffi__g4bdcd39cx2c90fb3d.pypy-26.so
WARNING: cannot read symbols for ...ojects/VirtualEnvs/relstoragepypy/site-packages/psycopg2cffi/_impl/__pycache__/_cffi__g5f6f4457x182e618d.pypy-26.so
WARNING: cannot read symbols for /usr/lib/system/libunc.dylib
WARNING: cannot read symbols for /usr/lib/system/liblaunch.dylib
WARNING: cannot read symbols for __LINKEDIT
WARNING: cannot read symbols for DefaultMallocZone_0x107e73000
WARNING: cannot read symbols for 1
WARNING: cannot read symbols for 0
//site-packages/vmprof/addrspace.py:168: UserWarning: there are only 0 profiles, data will be unreliable
  warnings.warn("there are only %d profiles, data will be unreliable" % (len(filtered_profiles),))
//site-packages/vmprof/addrspace.py:170: UserWarning: there are 4629 broken profiles out of 0, data will be unreliable
  warnings.warn("there are %d broken profiles out of %d, data will be unreliable" % (skipped, len(filtered_profiles)))
Traceback (most recent call last):
  File "//bin/vmprofshow", line 9, in <module>
    load_entry_point('vmprof==0.1.5.1', 'console_scripts', 'vmprofshow')()
  File "//site-packages/click/core.py", line 700, in __call__
    return self.main(*args, **kwargs)
  File "//site-packages/click/core.py", line 680, in main
    rv = self.invoke(ctx)
  File "//site-packages/click/core.py", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "//site-packages/click/core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "//site-packages/vmprof/show.py", line 115, in main
    pp.show(profile)
  File "//site-packages/vmprof/show.py", line 50, in show
    tree = stats.get_tree()
  File "//site-packages/vmprof/stats.py", line 75, in get_tree
    raise EmptyProfileFile()
EmptyProfileFile

vmprofwhow failed with exception: fail!

Hi! I tryed to run simple case and got an exception on view part:

C:\Python\Python27> .\python.exe .\Lib\site-packages\tests\cpuburn.py
Running for 30 seconds ..

Actual run-time: 1063.99989128 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1067.00015068 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1060.9998703 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1058.00008774 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1038.00010681 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1043.99991035 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1062.99996376 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1044.00014877 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1053.99990082 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1039.99996185 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1036.00001335 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1054.99982834 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1028.00011635 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1054.00013924 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1058.00008774 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1046.00000381 / Requested run-time: 1000, 15 iterations. Total iterations: 1500000
Actual run-time: 1001.99985504 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000
Actual run-time: 1036.00001335 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000
Actual run-time: 1060.9998703 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000
Actual run-time: 1012.99977303 / Requested run-time: 1000, 12 iterations. Total iterations: 1200000
Actual run-time: 1056.9999218 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000
Actual run-time: 1023.00000191 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1036.99994087 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1020.99990845 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1058.00008774 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1014.00017738 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1023.00000191 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1018.99981499 / Requested run-time: 1000, 13 iterations. Total iterations: 1300000
Actual run-time: 1009.00006294 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000
Actual run-time: 1025.00009537 / Requested run-time: 1000, 14 iterations. Total iterations: 1400000

Profile written to vmprof_cpuburn.dat.
To view the profile, run: vmprofshow vmprof_cpuburn.dat
C:\Python\Python27> .\Scripts\vmprofshow.exe .\vmprof_cpuburn.dat
←[37m←[1m100.0%←[0m ←[34m←[22m←[0m ←[34m←[1m<module>←[0m  ←[37m←[1m100.0%←[0m  ←[37m←[22m.\Lib\site-packages\tests/←[0m←
[37m←[1mcpuburn.py←[0m:←[37m←[22m1←[0m
←[37m←[1m100.0%←[0m ←[34m←[22m..←[0m ←[34m←[1mtest←[0m  ←[37m←[1m100.0%←[0m  ←[37m←[22m.\Lib\site-packages\tests/←[0m←[3
7m←[1mcpuburn.py←[0m:←[37m←[22m35←[0m
←[37m←[1m  0.0%←[0m ←[34m←[22m....←[0m ←[34m←[1m__init__←[0m  ←[37m←[1m0.0%←[0m  ←[37m←[22m.\Lib\site-packages\tests/←[0
m←[37m←[1mcpuburn.py←[0m:←[37m←[22m10←[0m
←[37m←[1m  0.0%←[0m ←[34m←[22m......←[0m ←[34m←[1m_next_rand←[0m  ←[37m←[1m100.0%←[0m  ←[37m←[22m.\Lib\site-packages\tes
ts/←[0m←[37m←[1mcpuburn.py←[0m:←[37m←[22m14←[0m
←[37m←[1m100.0%←[0m ←[34m←[22m....←[0m ←[34m←[1mburn←[0m  ←[37m←[1m100.0%←[0m  ←[37m←[22m.\Lib\site-packages\tests/←[0m←
[37m←[1mcpuburn.py←[0m:←[37m←[22m26←[0m
←[37m←[1m 99.9%←[0m ←[34m←[22m......←[0m ←[34m←[1m_iterate←[0m  ←[37m←[1m100.0%←[0m  ←[37m←[22m.\Lib\site-packages\tests
/←[0m←[37m←[1mcpuburn.py←[0m:←[37m←[22m19←[0m
←[37m←[1m 60.2%←[0m ←[34m←[22m........←[0m ←[34m←[1m_next_rand←[0m  ←[37m←[1m60.3%←[0m  ←[37m←[22m.\Lib\site-packages\te
sts/←[0m←[37m←[1mcpuburn.py←[0m:←[37m←[22m14←[0m
Traceback (most recent call last):
  File "c:\python\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python\Python27\Scripts\vmprofshow.exe\__main__.py", line 9, in <module>
  File "c:\python\python27\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "c:\python\python27\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "c:\python\python27\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python\python27\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 113, in main
    pp.show(profile)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 50, in show
    self._print_tree(tree)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 102, in _print_tree
    self._walk_tree(None, tree, 0, print_node)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 58, in _walk_tree
    self._walk_tree(node, c, level, callback)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 53, in _walk_tree
    callback(parent, node, level)
  File "c:\python\python27\lib\site-packages\vmprof\show.py", line 95, in print_node
    raise Exception("fail!")
Exception: fail!

It looks like a bug.
OS is Windows 8.1, Python version is 2.7, vmprof version is 0.2.3.1.

Vmprof crashes sometimes on Windows

Actually it happens very frequently (once in around 3 runs)
OS is Windows 8.1, Python version is 2.7, vmprof version is 0.2.3.1.

Faulting application name: python.exe, version: 0.0.0.0, time stamp: 0x5560ad83
Faulting module name: MSVCR90.dll, version: 9.0.30729.8387, time stamp: 0x51ea24a5
Exception code: 0xc0000417
Fault offset: 0x00069f9b
Faulting process ID: 0x1b78
Faulting application start time: 0x01d1545ba0da47c4
Faulting application path: C:\Python\Python27\python.exe
Faulting module path: C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387_none_5094ca96bcb6b2bb\MSVCR90.dll
Report ID: de95ccc2-c04e-11e5-8299-448a5ba34f1a
Faulting package full name: 
Faulting package-relative application ID: 

Please take a look at my capture, which is hosted here: http://www.fastswf.com/P8_n-do

"No module named _vmprof" error on Mac OS X 10.9.5 + pypy 2.6

Hi all,
When I run

#pypy -m vmprof test.py
No module named _vmprof; 'vmprof' is a package and cannot be directly executed

Another case:

#vmprofshow 
Traceback (most recent call last):
  File "<builtin>/app_main.py", line 75, in run_toplevel
  File "/vmprofshow", line 9, in <module>
    load_entry_point('vmprof==0.1.3', 'console_scripts', 'vmprofshow')()
  File "/site-packages/pkg_resources.py", line 352, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/site-packages/pkg_resources.py", line 2307, in load_entry_point
    return ep.load()
  File "/site-packages/pkg_resources.py", line 2021, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/site-packages/vmprof/__init__.py", line 7, in <module>
    import _vmprof
ImportError: No module named _vmprof

My environment:

  • mac os x 10.9.5
  • pypy 2.6

Thanks a lot :)

vmprof depends on Linux-specific tools

My use case is that I want to profile something with vmprof on a remote server and then analyze it on my OS X laptop.

I can't do this with vmprof, because I can't install gelf.h and dwarf.h and so forth. I don't think any of these are necessary for analyzing profiling data, and so I don't see why I should need to install them.

I guess the solution would be to split the package somehow.

Unable to build vmprof on Windows with Python 3.5.2

Hello people.

Linkage failed when building vmprof on Windows with Python 3.5.2 x86-64 and Visual Studio Community 2015 with Python support.

Here the log:

C:\Users\Marc>pip install vmprof
Collecting vmprof
  Using cached vmprof-0.2.8.tar.gz
Requirement already satisfied (use --upgrade to upgrade): requests in c:\python35\lib\site-packages (from vmprof)
Installing collected packages: vmprof
  Running setup.py install for vmprof ... error
    Complete output from command c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='D:\\Temp\\Users\\Marc\\pip-build-d2p21sz2\\vmprof\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record D:\Temp\Users\Marc\pip-dtex470n-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\tests
    copying tests\cpuburn.py -> build\lib.win-amd64-3.5\tests
    copying tests\test_config.py -> build\lib.win-amd64-3.5\tests
    copying tests\test_reader.py -> build\lib.win-amd64-3.5\tests
    copying tests\test_run.py -> build\lib.win-amd64-3.5\tests
    copying tests\test_stats.py -> build\lib.win-amd64-3.5\tests
    copying tests\__init__.py -> build\lib.win-amd64-3.5\tests
    creating build\lib.win-amd64-3.5\vmprof
    copying vmprof\binary.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\cli.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\profiler.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\reader.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\show.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\stats.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\upload.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\vmprofdemo.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\__init__.py -> build\lib.win-amd64-3.5\vmprof
    copying vmprof\__main__.py -> build\lib.win-amd64-3.5\vmprof
    creating build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\constants.py -> build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\marks.py -> build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\merge_point.py -> build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\objects.py -> build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\parser.py -> build\lib.win-amd64-3.5\vmprof\log
    copying vmprof\log\__init__.py -> build\lib.win-amd64-3.5\vmprof\log
    running egg_info
    writing requirements to vmprof.egg-info\requires.txt
    writing top-level names to vmprof.egg-info\top_level.txt
    writing vmprof.egg-info\PKG-INFO
    writing entry points to vmprof.egg-info\entry_points.txt
    writing dependency_links to vmprof.egg-info\dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'vmprof.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'vmprof.egg-info\SOURCES.txt'
    running build_ext
    building '_vmprof' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python35\include -Ic:\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" /Tcsrc/_vmprof.c /Fobuild\temp.win-amd64-3.5\Release\src/_vmprof.obj
    _vmprof.c
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_common.h(67): warning C4311: 'cast de type' : troncation de pointeur de 'PyCodeObject *' à 'unsigned long'
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_common.h(67): warning C4312: 'cast de type' : la conversion de 'unsigned long' en 'void *' d'une taille supérieure
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_common.h(96): warning C4267: '=' : conversion de 'size_t' en 'char', perte possible de données
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_main_win32.h(31): warning C4267: 'fonction' : conversion de 'size_t' en 'unsigned int', perte possible de données
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_main_win32.h(48): warning C4267: 'initialisation' : conversion de 'size_t' en 'int', perte possible de données
    d:\temp\users\marc\pip-build-d2p21sz2\vmprof\src\vmprof_main_win32.h(72): warning C4312: 'cast de type' : la conversion de 'DWORD' en 'void *' d'une taille supérieure
    src/_vmprof.c(42): warning C4311: 'cast de type' : troncation de pointeur de 'PyCodeObject *' à 'unsigned long'
    src/_vmprof.c(42): warning C4312: 'cast de type' : la conversion de 'unsigned long' en 'void *' d'une taille supérieure
    src/_vmprof.c(69): warning C4311: 'cast de type' : troncation de pointeur de 'PyCodeObject *' à 'unsigned long'
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\python35\libs /LIBPATH:c:\python35\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\um\x64" /EXPORT:PyInit__vmprof build\temp.win-amd64-3.5\Release\src/_vmprof.obj /OUT:build\lib.win-amd64-3.5\_vmprof.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\src\_vmprof.cp35-win_amd64.lib
    _vmprof.obj : warning LNK4197: exportation 'PyInit__vmprof' spÚcifiÚe Ó plusieurs reprisesá; premiÞre spÚcification utilisÚe
       CrÚation de la bibliothÞque build\temp.win-amd64-3.5\Release\src\_vmprof.cp35-win_amd64.lib et de l'objet build\temp.win-amd64-3.5\Release\src\_vmprof.cp35-win_amd64.exp
    _vmprof.obj : error LNK2001: symbole externe non rÚsolu _PyThreadState_Current
    build\lib.win-amd64-3.5\_vmprof.cp35-win_amd64.pyd : fatal error LNK1120: 1 externes non rÚsolus
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\link.exe' failed with exit status 1120

    ----------------------------------------
Command "c:\python35\python.exe -u -c "import setuptools, tokenize;__file__='D:\\Temp\\Users\\Marc\\pip-build-d2p21sz2\\vmprof\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record D:\Temp\Users\Marc\pip-dtex470n-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in D:\Temp\Users\Marc\pip-build-d2p21sz2\vmprof\

Thank you. ;)

Start profiling multiple times

When starting profiling multiple times (using different profile log files), the following traceback is relative frequent (triggered when reading in the stats tree):

  File "/home/oberstet/pypy260_1/site-packages/crossbar-0.11.0-py2.7.egg/crossbar/common/profiler.py", line 139, in convert_profile
    tree = stats.get_tree()
  File "/home/oberstet/pypy260_1/site-packages/vmprof-0.0.9-py2.7.egg/vmprof/stats.py", line 67, in get_tree
    top_addr = self.profiles[0][0][0]
exceptions.IndexError: list index out of range

0.2.2 fails to build

Python 3.5/Arch Linux

$ pip install --user --no-deps --vvv vmprof
<elided>
    building '_vmprof' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fPIC -I/usr/include/python3.5m -c src/_vmprof.c -o build/temp.linux-x86_64-3.5/src/_vmprof.o -Wno-unused
    In file included from src/_vmprof.c:29:0:
    src/vmprof_main.h: In function ‘get_current_thread_state’:
    src/vmprof_main.h:101:12: error: ‘_PyThreadState_Current’ undeclared (first use in this function)
         return _PyThreadState_Current;
                ^
    src/vmprof_main.h:101:12: note: each undeclared identifier is reported only once for each function it appears in
    In file included from src/_vmprof.c:29:0:
    src/vmprof_main.h: In function ‘vmprof_register_virtual_function’:
    src/vmprof_main.h:348:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (freesize < blocklen) {
                              ^
    In file included from src/_vmprof.c:29:0:
    src/vmprof_main.h: In function ‘get_current_thread_state’:
    src/vmprof_main.h:103:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    error: command 'gcc' failed with exit status 1

Everything is undefined?

I run a script under vmprof and vmprof -n;
What is does it roughly:

  • spawn N worker threads
  • wait for these threads

Each worker does:

  • make an HTTP PUT using libcurl
  • poll for resource to become readable using HTTP GET, time.sleep() in between.

vmprof-undefined

vmprof.show always raises vmprof.stats.EmptyProfileFile exception

For any profile the following exception is raised:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vmprof-0.1.5.5-py2.7-macosx-10.6-intel.egg/vmprof/show.py", line 117, in <module> main() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click-6.2-py2.7.egg/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click-6.2-py2.7.egg/click/core.py", line 696, in main rv = self.invoke(ctx) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click-6.2-py2.7.egg/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click-6.2-py2.7.egg/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vmprof-0.1.5.5-py2.7-macosx-10.6-intel.egg/vmprof/show.py", line 113, in main pp.show(profile) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vmprof-0.1.5.5-py2.7-macosx-10.6-intel.egg/vmprof/show.py", line 48, in show tree = stats.get_tree() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vmprof-0.1.5.5-py2.7-macosx-10.6-intel.egg/vmprof/stats.py", line 100, in get_tree top = self.get_top(self.profiles) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vmprof-0.1.5.5-py2.7-macosx-10.6-intel.egg/vmprof/stats.py", line 74, in get_top raise EmptyProfileFile() vmprof.stats.EmptyProfileFile

Installation broken on Fedora because other lib structures

On fedora after installing libdwarf-devel (and other from family), libdwarf.h and dwarf.h are located in /usr/include/libdwarf not in /usr/include/, so the installation crashes:
src/hotpatch/elf.c:9:19: fatal error: dwarf.h: No such file or directory

After copying both files level up, then it crashes:
src/hotpatch/elf.c:15:25: fatal error: libelf/gelf.h: No such file or directory
gelf.h is NOT in subdirectory, copying file to libelf subdir solves the problem.

below are packages contents

$ rpm -ql libdwarf-devel-20150115-1.fc21.x86_64
/usr/include/libdwarf
/usr/include/libdwarf/dwarf.h
/usr/include/libdwarf/libdwarf.h
/usr/lib64/libdwarf.so
$ rpm -ql elfutils-libelf-devel.x86_64         
/usr/include/gelf.h
/usr/include/libelf.h
/usr/include/nlist.h
/usr/lib64/libelf.so

breaks on a simple script

Sorry my script application.py is propriatory.
If the error is not obvious, please let me know and I can strip that down or obfuscate it

(plc)[dima@bmg 18src]$ python -m vmprof --web http://localhost:8000/ application.py
Compiling and uploading to http://localhost:8000/...
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/dima/plc/lib/python2.7/site-packages/vmprof-0.0.9-py2.7-linux-x86_64.egg/vmprof/__main__.py", line 105, in <module>
    main()
  File "/dima/plc/lib/python2.7/site-packages/vmprof-0.0.9-py2.7-linux-x86_64.egg/vmprof/__main__.py", line 102, in main
    show_stats(prof_file.name, output_mode, args)
  File "/dima/plc/lib/python2.7/site-packages/vmprof-0.0.9-py2.7-linux-x86_64.egg/vmprof/__main__.py", line 74, in show_stats
    vmprof.com.send(stats, args)
  File "/dima/plc/lib/python2.7/site-packages/vmprof-0.0.9-py2.7-linux-x86_64.egg/vmprof/com.py", line 13, in send
    "profiles": t.get_tree().flatten()._serialize(),
  File "/dima/plc/lib/python2.7/site-packages/vmprof-0.0.9-py2.7-linux-x86_64.egg/vmprof/stats.py", line 67, in get_tree
    top_addr = self.profiles[0][0][0]
IndexError: list index out of range

Hide importlib stack in visualization?

Since the switch to pure-python importlib, importing a module brings in a bunch of functions to the call stack (_find_and_load, _find_and_load_unlocked,_load_unlocked,exec_module,_call_with_frames_removed`, etc.) Typically this shouldn't be an issue, except when profiling a startup where import time is significant.
Perhaps these should be special-cased and hidden away (like for traceback display)?

vmprof generates malfunction output with 64 bit Python in Windows

Synopsis:

>python -m vmprof -o prof-x64.log sometest.py

>python -m vmprof.upload prof-x64.log
Traceback (most recent call last):
  File "C:\Python27_x64\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27_x64\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27_x64\lib\site-packages\vmprof\upload.py", line 105, in <module>
    main()
  File "C:\Python27_x64\lib\site-packages\vmprof\upload.py", line 94, in main
    stats = vmprof.read_profile(args.profile)
  File "C:\Python27_x64\lib\site-packages\vmprof\profiler.py", line 34, in read_profile
    period, profiles, virtual_symbols, interp_name = read_prof(prof_file)
  File "C:\Python27_x64\lib\site-packages\vmprof\reader.py", line 172, in read_prof
    assert read_word(fileobj) == 0 # header count
  File "C:\Python27_x64\lib\site-packages\vmprof\binary.py", line 19, in read_word
    r = int(struct.unpack('l', b)[0])
struct.error: unpack requires a string argument of length 4

>python -V
Python 2.7.12

>python -c "import sys; print(sys.version)"
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]

It works with x86 Python:

>python -m vmprof -o prof-x86.log sometest.py

>python -m vmprof.upload prof-x86.log
Compiling and uploading to http://vmprof.com...
VMProf log: http://vmprof.com/#/e6881666e8da424f33b18ecfd767d708

C:\Working\Repositories>python -V
Python 2.7.12

C:\Working\Repositories>python -c "import sys; print(sys.version)"
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
>python -m vmprof.upload prof-x64.log
Traceback (most recent call last):
  File "C:\Python27_x86\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27_x86\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27_x86\lib\site-packages\vmprof\upload.py", line 105, in <module>
    main()
  File "C:\Python27_x86\lib\site-packages\vmprof\upload.py", line 94, in main
    stats = vmprof.read_profile(args.profile)
  File "C:\Python27_x86\lib\site-packages\vmprof\profiler.py", line 34, in read_profile
    period, profiles, virtual_symbols, interp_name = read_prof(prof_file)
  File "C:\Python27_x86\lib\site-packages\vmprof\reader.py", line 231, in read_prof
    assert not marker, (fileobj.tell(), repr(marker))
AssertionError: (69L, "'0'")

The content of sometest.py:

import time

for _ in xrange(1000):
    time.sleep(.001)

Feel free to ask for additional information which can help to resolve this issue. Thanks!

Problem using FILE * and fileno with vmprof.disable

Hello,

interestingly the code worked like a charm with named temporary files from the tempfile module, but started to act up, once I use a FILE * on it.

I am getting this in the end, after seemingly vm.enable did its job.

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/vmprof/init.py", line 52, in disable
f = os.fdopen(os.dup(_prof_fileno), "rb")
OSError: [Errno 22] Invalid argument

The code I use is like this (excerpt):

FILE *tempfile;
tempfile = fopen("nuitka-performance.dat", "wb");

PyObject *result = CALL_FUNCTION_WITH_ARGS2(
    PyObject_GetAttrString( vmprof_module, "enable"),
     PyInt_FromLong( fileno( tempfile ) ),
     PyFloat_FromDouble( 0.001 )
);

and later:

PyObject *result = CALL_FUNCTION_NO_ARGS(
    PyObject_GetAttrString( vmprof_module, "disable")
);
fclose( tempfile );

Is there anything that causes the fileno to go bad? I even tried to not close the file myself. I am now just ignoring any errors from disable as a workaround. But probably you are in fact expecting more than a file number, rather a Python object behind it at some place otherwise?

Yours,
Kay

Please add an explicit LICENSE file.

What license is this code being released under? (nobody other than the authors can touch it without that)

Thanks! (sounds like a great project)

can't profile tests under nose

I tried following:

create tests/run.py like this:

import sys, nose
sys.argv = [__file__, "--with-xxx", "tests"]
nose.main()

This runs 700-odd tests and takes ~10s.

When I run it under python -m vmprof --web ..., I get:

  • a nice plot of all nose internals
  • only one occurrence of one test file as <module>
  • no occurrences of code under test

Extension module must be linked with librt on Linux

While trying out vmprof (git clone; python setup.py develop), I've ran into this (Ubuntu 12.04 x86_64):

% python -c 'import vmprof'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "vmprof/__init__.py", line 4, in <module>
    import _vmprof
ImportError: ./_vmprof.so: undefined symbol: clock_gettime

...which is due to clock_gettime being defined in librt.so

A simple patch

--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,7 @@ else:
                                'src/vmprof.c',
                                ],
                             extra_compile_args=['-Wno-unused'],
-                            libraries=['elf', 'unwind'],
+                            libraries=['elf', 'unwind', 'rt'],
                             extra_link_args=['%s' % libdwarf])]

would fix the issue, though not in a portable way (at least some BSDs have this function defined in libc).

Not a pull request as I haven't found a clean&reliable way to do this yet (autotools folks just test it, but distutils does not seem to be flexible enough).

Vmprof doesn't run on linux with latest PyPy

I tried to measure one of my scripts using latest PyPy (4.1.0-alpha0) on Linux, but unfortunately I got such error:
'''
Traceback (most recent call last):
File "/home/hatari/pypy/lib-python/2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/home/hatari/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/hatari/pypy/site-packages/vmprof/main.py", line 69, in
main()
File "/home/hatari/pypy/site-packages/vmprof/main.py", line 54, in main
vmprof.enable(prof_file.fileno(), args.period)
File "/home/hatari/pypy/site-packages/vmprof/init.py", line 43, in enable
_vmprof.enable(fileno, period)
VMProfError: libunwind.so: cannot open shared object file: No such file or directory
'''
Could you please advise me something here? Or it's a bug?
Vmprof version is 0.2.3.2.

Python3 uploading issue with bytes/str

$ echo 'for _ in range(int(1e8)): pass' > foo.py && python3 -mvmprof --web foo.py
<elided WARNINGS regarding unreadable symbols>
/home/antony/.local/lib/python3.5/site-packages/vmprof/addrspace.py:170: UserWarning: there are 136 broken profiles out of 1091, data will be unreliable
  warnings.warn("there are %d broken profiles out of %d, data will be unreliable" % (skipped, len(filtered_profiles)))
Compiling and uploading to http://vmprof.com...
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/antony/.local/lib/python3.5/site-packages/vmprof/__main__.py", line 67, in <module>
    main()
  File "/home/antony/.local/lib/python3.5/site-packages/vmprof/__main__.py", line 64, in main
    show_stats(prof_file.name, output_mode, args)
  File "/home/antony/.local/lib/python3.5/site-packages/vmprof/__main__.py", line 25, in show_stats
    upload_stats(stats, args)
  File "/home/antony/.local/lib/python3.5/site-packages/vmprof/__main__.py", line 36, in upload_stats
    res = vmprof.upload.upload(stats, name, argv, host, auth)
  File "/home/antony/.local/lib/python3.5/site-packages/vmprof/upload.py", line 35, in upload
    return "http://" + host + "/#/" + val[1:-1]
TypeError: Can't convert 'bytes' object to str implicitly

Note that the file is actually uploaded correctly.

Arch Linux standard packages (Python 3.5.0).

pip install vmprof does not install six depecy

Traceback (most recent call last):
  File "C:\Miniconda2\envs\test-vmprof\lib\runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "C:\Miniconda2\envs\test-vmprof\lib\runpy.py", line 111, in _get_module_details
    __import__(mod_name)  # Do not catch exceptions initializing package
  File "C:\Miniconda2\envs\test-vmprof\lib\site-packages\vmprof\__init__.py", line 4, in <module>
    from . import cli
  File "C:\Miniconda2\envs\test-vmprof\lib\site-packages\vmprof\cli.py", line 4, in <module>
    from six.moves import configparser
ImportError: No module named six.moves

Segfault when profiling service

Apparently I don't quite have all the debugging symbols installed that I want, but here's the stack trace:

Core was generated by `/home/ubuntu/.virtualenvs/flocker-dbg/bin/python -m vmprof -o flocker-control.v'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f9bd429d245 in vmprof_unw_step (cp=0x7fffc14a6770, first_run=0) at src/vmprof.c:135
135     src/vmprof.c: No such file or directory.
(gdb) bt
#0  0x00007f9bd429d245 in vmprof_unw_step (cp=0x7fffc14a6770, first_run=0) at src/vmprof.c:135
#1  0x00007f9bd429d484 in get_stack_trace (result=0x7fffc14a6bb8, max_depth=1023, ucontext=0x7fffc14a8bc0,
    thread_id=0x7fffc14a6ba8) at src/vmprof.c:213
#2  0x00007f9bd429d531 in sigprof_handler (sig_nr=27, info=0x7fffc14a8cf0, ucontext=0x7fffc14a8bc0) at src/vmprof.c:232
#3  <signal handler called>
#4  cpyprof_PyEval_EvalFrameEx (f=0x7f9bd4299db1 <cpyprof_PyEval_EvalFrameEx>, throwflag=44270928) at src/_vmprof.c:44
#5  0x00000000409e6015 in ?? ()
#6  0x00007f9bd0b67b28 in ?? ()
#7  0x00007fffc14a92f0 in ?? ()
#8  0x0000000002a386d8 in ?? ()
#9  0x0000000000524b9a in PyEval_EvalCodeEx (co=0x0, globals=0x0, locals=0x0, args=0x0, argcount=0, kws=0x0,
    kwcount=5393306, defs=0x7f9b00000000, defcount=0, closure=0x2af79a8) at ../Python/ceval.c:3252
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

vmprof.disable() fails on CPython 3.4

Traceback (most recent call last):
  File "./main.py", line 39, in <module>
    vmprof.disable()
  File "/home/vagrant/vmprof-python/vmprof/__init__.py", line 53, in disable
    _virtual_ips_so_far = read_prof(f, virtual_ips_only=True)
  File "/home/vagrant/vmprof-python/vmprof/reader.py", line 101, in read_prof
    assert read_word(fileobj) == 0 # header count
  File "/home/vagrant/vmprof-python/vmprof/reader.py", line 87, in read_word
    b = fileobj.read(8)
OSError: [Errno 9] Bad file descriptor

sys.path not being correctly set up

Given the foo/bar.py with import subdir and an empty foo/subdir/__init__.py, running python foo/bar.py exits with no exceptions printed and with an exit code of zero, however python -m vmprof foo/bar.py throws ImportError:

Traceback (most recent call last):
  File "/opt/pypy/lib-python/2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/mnt/home-extra/gsnedders/Documents/other-projects/csswg-testsuite-pypy-env/site-packages/vmprof/__main__.py", line 69, in <module>
    main()
  File "/mnt/home-extra/gsnedders/Documents/other-projects/csswg-testsuite-pypy-env/site-packages/vmprof/__main__.py", line 58, in main
    runpy.run_path(args.program, run_name='__main__')
  File "/opt/pypy/lib-python/2.7/runpy.py", line 240, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "foo/bar.py", line 1, in <module>
    import subdir
ImportError: No module named subdir

This seems to be down to sys.path[0] differing between the two (sys.path[1:] is equal): without vmprof, it's the path to ./foo; with vmprof, it's '').

Total time passed is missing

Hello,

I believe the total time elapsed is missing from the cli and web outputs at least, and I believe also from the file. When making comparisons, a relative time shift is important though. And esp. for differences between runs it's essential.

Can you add this information?

Yours,
Kay

'no stats' when profiling numpy on anaconda 3.5

Profiling the following script:

import numpy as np

n = 5000
a = np.random.random((n, n))
b = np.random.random((n, n))
c = np.dot(np.abs(a), b)

Produces:

macbook-pro-4:test_profiler0 traff$ /Users/traff/anaconda/bin/python3.5 -m vmprof test_numpy.py 
no stats
macbook-pro-4

Mac OSX 10.11.5
Anaconda 3 - 4.0.0 - 64
vmprof 0.2.7

vmprofshow fails to process file saved from vmprof

I used vmprof to output profiling information for something that was running on a remote machine, in the hope of analyzing the file separately.

However, after running the process and gathering the data, when I try to view the file with vmprofshow I get an error:

$ vmprofshow flocker-control.vmprof
Fatal: could not read vmprof profile file 'flocker-control.vmprof': list index out of range
[52071 refs]

It should be noted that the original vmprof process segfaulted.

Build error on OS X 10.9.5

I get the following build error on OS X 10.9.5.

$ python setup.py build
...
building '_vmprof' extension
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I/opt/local/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/_vmprof.c -o build/temp.macosx-10.9-x86_64-3.5/src/_vmprof.o -Wno-unused
In file included from src/_vmprof.c:31:
In file included from src/vmprof_main.h:34:
src/vmprof_mt.h:69:46: error: use of undeclared identifier 'MAP_ANONYMOUS'
                               MAP_PRIVATE | MAP_ANONYMOUS,

I'm not sure how you want to handle this (ifdef, platform check, or just switching to MAP_ANON), but the following works on my machine at least

diff --git a/src/vmprof_mt.h b/src/vmprof_mt.h
index bff40d4..7090102 100644
--- a/src/vmprof_mt.h
+++ b/src/vmprof_mt.h
@@ -65,7 +65,7 @@ static int prepare_concurrent_bufs(void)
     unprepare_concurrent_bufs();
     profbuf_all_buffers = mmap(NULL, sizeof(struct profbuf_s) * MAX_NUM_BUFFERS,
                                PROT_READ | PROT_WRITE,
-                               MAP_PRIVATE | MAP_ANONYMOUS,
+                               MAP_PRIVATE | MAP_ANON,
                                -1, 0);
     if (profbuf_all_buffers == MAP_FAILED) {
         profbuf_all_buffers = NULL;

This mentions that MAP_ANONYMOUS is only available on OS X 10.11 and later.

$ grep ANON /usr/include/sys/mman.h
#define MAP_ANON    0x1000  /* allocated from memory, swap space */

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.9.5

Thanks

vmprofshow and vmprof.read_profile() can't read a vmprof file

I am trying to use vmprof to profile a WSGI application running through gunicorn. I have, at the bottom of my main module, this:

import os
import vmprof
fp = open("/tmp/vmprof.out-%s" % os.getpid(), "w")
vmprof.enable(fp.fileno(), warn=False)

def disable_at_exit():
    vmprof.disable()
    fp.close()

import atexit
atexit.register(disable_at_exit)

The file that results from this -- https://www.dropbox.com/s/ch33nyh9a2zp9vv/vmprof.out.gz?dl=0 for example -- can't be read with vmprofshow or vmprof.read_profile():

[email protected]:~ $ /usr/local/opt/pypy/bin/vmprofshow ./vmprof.out
Fatal: could not read vmprof profile file './vmprof.out':
>>>> import vmprof
>>>> vmprof.read_profile("vmprof.out")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/opt/pypy-2.6-linux_x86_64-portable/site-packages/vmprof/profiler.py", line 54, in read_profile
    virtual_only, include_extra_info, interp_name)
  File "/usr/local/opt/pypy-2.6-linux_x86_64-portable/site-packages/vmprof/addrspace.py", line 141, in filter_addr
    interp_name, extra_info, only_virtual)
  File "/usr/local/opt/pypy-2.6-linux_x86_64-portable/site-packages/vmprof/addrspace.py", line 109, in _next_profile
    assert jitting
AssertionError
>>>>

CC @fijal

Docs describe non-existent vmprof.upload

The docs say:

To upload an already saved profile log to the vmprof web server:
python -m vmprof.upload output.log

However, when I try to run this I get the following:

$ python -m vmprof.upload flocker-control.vmprof
/home/ubuntu/.virtualenvs/flocker-dbg/bin/python: No module named vmprof.upload

I have vmprof==0.1.4.2

Running from terminal with -O produces no stats

I've been trying to benchmark an application with optimizations triggered by python's -O flag [1]. In this case, vmprof does not generate output unless an output file is set via -o as well. This breaks printing to the terminal and, worse, the --web option.
Tested with python 2.7 and 3.4, vmprof 0.2.7.

I can reliably replicate using this program as simple.py:

#!/usr/bin/python
print(__debug__)

def foo():
    pass

for _ in range(int(1E5)):
    foo()

And calling vmprof from the command line:

$ python -O -m vmprof simple.py
False
no stats
$ python -m vmprof simple.py
True
 vmprof output:
 %:      name:                location:
 100.0%  _run_code            /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py:62
 100.0%  <module>             simple.py:2
 100.0%  _run_module_as_main  /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py:136
 100.0%  <module>             /usr/local/lib/python2.7/site-packages/vmprof/__main__.py:1
 100.0%  run_path             /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py:223
 100.0%  _run_module_code     /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py:75
 100.0%  main                 /usr/local/lib/python2.7/site-packages/vmprof/__main__.py:37

[1]
The __debug__ constant, actually.

Confusing default period.

The doc says:

vmprof.enable(fileno, period=0.099, memory=False) - enable writing vmprof data to a file described by a fileno file descriptor. Timeout is in float seconds. The minimal available resolution is 4ms, we’re working on improving that (note the default is 9.9ms).
https://vmprof.readthedocs.io/en/latest/#module-level-functions

0.099sec = 99ms, not 9.9ms.

And code is (vmprof/__init__.py):

# it's not a good idea to use a "round" default sampling period, else we risk
# to oversample periodic tasks which happens to run at e.g. 100Hz or 1000Hz:
# http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_Hints_Tips#profile-1001.2C_profile-997.3F
#
# To avoid the problem, we use a period which is "almost" but not exactly
# 1000Hz
DEFAULT_PERIOD = 0.00099

0.00099 = 0.99ms ?

Hides errors thrown by the profiled program

If the profiled program throws an error, vmprof never shows it to the user (and then the CLI crashes due to #1 because a script that errored out is too short to be profiled).
It seems that in vmprof/__main__.py:main:

    try:
        sys.argv = [args.program] + args.args
        runpy.run_path(args.program, run_name='__main__')
    finally:
        vmprof.disable()
        show_stats(prof_file.name, output_mode, args)

you can simply have an except: with some logging

please tag releases and include release notes

Just noticed there was a new release of vmprof. Looked for a changelog under https://pypi.python.org/pypi/vmprof, https://vmprof.readthedocs.org/, and https://github.com/vmprof/vmprof-python, but didn't find any. Went to https://github.com/vmprof/vmprof-python/releases in hopes of seeing this info there, but came up empty since you're not tagging releases.

Would you consider tagging releases and adding release notes? In the meantime, users have to look through https://github.com/vmprof/vmprof-python/commits to try to tease out what's changed when there's a new release.

Here is an example of maintaining release notes alongside each release: https://github.com/jab/bidict/releases

Check out https://github.com/blog/1547-release-your-software for a walkthrough of using this feature.
GitHub makes this a really nice user experience.

Thanks for your consideration and for the great work on vmprof.

<unknown code> <unknown> when copying vmprof log while it is being written

If I have a process that is writing the vmprof log, and copy the log file to be able to see the current profiling information without stopping the process, the log does not contain source information: http://vmprof.com/#/6b1f680490d6ac2d2adb41859a510718, and vmprofshow displays most lines as X% <unknown code> X% <unknown>. If I stop the process then the source information is displayed correctly. I can reproduce it on CPython 3.4 and 3.5 on OS X and Ubuntu.

Is it a bug, or I need to stop the process to get full profile information?

vmprofshow cannot handle PyPy profile output

vmprofshow is able to read and display the profiles generated by CPython, but crashes when populating the output for a profile generated by PyPy. Below is the traceback for the profile of cpuburn benchmark run under PyPy.

12:24:33 $ vmprofshow vmprof_cpuburn.dat
100.0%  <module>  100.0%  tests/cpuburn.py:1
Traceback (most recent call last):
  File "/home/spenser/pypy-env/bin/vmprofshow", line 9, in <module>
    load_entry_point('vmprof==0.2.3.2', 'console_scripts', 'vmprofshow')()
  File "/home/spenser/pypy-env/site-packages/click-6.2-py2.7.egg/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/spenser/pypy-env/site-packages/click-6.2-py2.7.egg/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/spenser/pypy-env/site-packages/click-6.2-py2.7.egg/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/spenser/pypy-env/site-packages/click-6.2-py2.7.egg/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 113, in main
    pp.show(profile)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 50, in show
    self._print_tree(tree)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 102, in _print_tree
    self._walk_tree(None, tree, 0, print_node)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 58, in _walk_tree
    self._walk_tree(node, c, level, callback)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 53, in _walk_tree
    callback(parent, node, level)
  File "/home/spenser/pypy-env/site-packages/vmprof-0.2.3.2-py2.7.egg/vmprof/show.py", line 95, in print_node
    raise Exception("fail!")
Exception: fail!

System info:

$ pypy --version
Python 2.7.10 (4.0.1+dfsg-1~ppa1~ubuntu15.04, Nov 20 2015, 19:34:27)
[PyPy 4.0.1 with GCC 4.9.2]

$ uname -a
Linux Mentat 4.2.0-25-generic #30-Ubuntu SMP Mon Jan 18 12:31:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

vmprofshow invalid arguments to `read_profile`

vmprofshow is calling read_profile with additional arguments, causing an error:

Fatal: could not read vmprof profile file 'vmprof.log': read_profile() got an unexpected keyword argument 'virtual_only'

Call (source):

stats = vmprof.read_profile(profile, virtual_only=True, include_extra_info=True)

Signature (source):

def read_profile(prof_filename):

Profiling scripts which call compiled code

I work on a project where a main python script drives the execution. In this script, most of the computation is done in a homemade library, let say _foo.so, in Fortran (I know, it isn't mainstream).

The thing is that when I look at the profiling result, I see this. I really would like to get more details about the function nlgs_ExSolver during this execution.

The python function really looks like:

  def nlgs_ExSolver(*args):
    return _foo.nlgs_ExSolver(*args)

Question:
Is there a way to allow VMprof to profile execution costs of functions that from my _foo library?
If it is not possible, do you know a project which can achieve this exploit?

Build errors

I'm seeing the following when running python setup.py install on an older machine.

In file included from src/vmprof.c:19:
src/getpc.h:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘callunrollinfo’
src/getpc.h: In function ‘GetPC’:
src/getpc.h:142: error: ‘reinterpret_cast’ undeclared (first use in this function)
src/getpc.h:142: error: (Each undeclared identifier is reported only once
src/getpc.h:142: error: for each function it appears in.)
src/getpc.h:142: error: expected expression before ‘char’
src/getpc.h:143: error: ‘for’ loop initial declarations are only allowed in C99 mode
src/getpc.h:143: note: use option -std=c99 or -std=gnu99 to compile your code
src/getpc.h:143: error: ‘callunrollinfo’ undeclared (first use in this function)
$ gcc44 --version
gcc44 (GCC) 4.4.7 20120313 (Red Hat 4.4.7-1)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I see reinterpret_cast in the included header file, but the file that includes it seems to be C, based on the file extension. Is this code meant to be C++ or C?

Thanks

vmprofshow running under python cannot load files generated with pypy

import vmprof

document = """
  a: 1
  b:
    c: 3
    d: 4
"""
f = open('dump.log','w')
vmprof.enable(f.fileno())
for i in xrange(10000):
    yaml.dump(yaml.load(document))
vmprof.disable()

$ pypy test.py

$ vmprofshow  dump.log
  Fatal: could not read vmprof profile file 'dump.log': an integer is required

running under pypy vmprofshow works

Error when parsing vmprof ouput on OS X 10.11

pypy -m vmprof program.py fails:

$ python
Python 2.7.10 (65ac40781e5e, Oct 21 2015, 07:05:18)
[PyPy 4.0.0 with GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
$ pip freeze | grep vmprof
vmprof==0.1.5.3
$ python -m vmprof ~/programming/bench/fib.py
Traceback (most recent call last):
  File "/Users/kostia/opt/pypy-c-jit-80368-65ac40781e5e-osx64/lib-python/2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Users/kostia/opt/pypy-c-jit-80368-65ac40781e5e-osx64/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/__main__.py", line 67, in <module>
    main()
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/__main__.py", line 64, in main
    show_stats(prof_file.name, output_mode, args)
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/__main__.py", line 19, in show_stats
    virtual_only=not args.enable_nonvirtual
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/profiler.py", line 31, in read_profile
    period, profiles, virtual_symbols, libs, interp_name = read_prof(prof)
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/reader.py", line 173, in read_prof
    symmap = read_ranges(fileobj.read())
  File "/Users/kostia/apps/netdb_demo_2/pypy/site-packages/vmprof/reader.py", line 90, in read_ranges
    start, end = parts[0].split('-')
ValueError: expected length 2, got 1

If I ignore the error and print parts (with additional !!), I get the following https://gist.github.com/lopuhin/45fb12202cf73e130d58

vmprof.read_profile interface unpractical

Hello,

the interface "vmprof.read_profile" accepts a filename. It should accept a readable instead. When I meant to add a small header with start and end date, that wouldn't work without duplicating the code there that just opens the binary data there.

Yours,
Kay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.