Use cProfile instead of profile

I can't open .prof files created with 'profile' using pyprof2calltree:

```
Traceback (most recent call last):
  File "/home/val/.local/bin/pyprof2calltree", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/val/.local/lib/python3.11/site-packages/pyprof2calltree.py", line 339, in main
    kg = CalltreeConverter(pstats.Stats(args.infile))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/val/.local/lib/python3.11/site-packages/pyprof2calltree.py", line 178, in __init__
    self.entries = pstats2entries(profiling_data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/val/.local/lib/python3.11/site-packages/pyprof2calltree.py", line 135, in pstats2entries
    cc, nc, tt, ct = call_info
    ^^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable int object
```
This commit is contained in:
Valentin Lorentz 2024-08-02 07:49:45 +02:00
parent bb120edbb1
commit 72e90b6972

View File

@ -361,11 +361,11 @@ def main():
owner = Owner.Class() owner = Owner.Class()
if options.profile: if options.profile:
import profile import cProfile
world.profiling = True world.profiling = True
profile.runctx('run()', cProfile.runctx('run()',
globals=globals(), locals={**locals(), "run": run}, globals=globals(), locals={**locals(), "run": run},
filename='%s-%i.prof' % (nick, time.time())) filename='%s-%i.prof' % (nick, time.time()))
else: else:
run() run()