baverman / flameprof

Flamegraph generator for cProfile stats
MIT License
237 stars 15 forks source link

ZeroDivisionError: float division by zero #9

Open cpys opened 4 years ago

cpys commented 4 years ago

when i try to render the svg file by myself, i got exception like this

  File "profmiddleware.py", line 37, in post_prof
    flameprof.render(pr.stats, flameprof.get_out(svg_file_name))
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 305, in render
    blocks, bblocks, maxw = prepare(funcs, calls, threshold=threshold)
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 232, in prepare
    _calc_back((f for f in funcs if f != 'root'), 0, None, 0, set(), 0)
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 225, in _calc_back
    _calc_back(func['called'], level+1, name, origin, visited | {key}, ttt)
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 225, in _calc_back
    _calc_back(func['called'], level+1, name, origin, visited | {key}, ttt)
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 225, in _calc_back
    _calc_back(func['called'], level+1, name, origin, visited | {key}, ttt)
  [Previous line repeated 2 more times]
  File "/home/cpys/anaconda3/lib/python3.8/site-packages/flameprof.py", line 199, in _calc_back
    factor = pw / sum(calls[(r, to)][3] for r in names)
ZeroDivisionError: float division by zero
flameprof.render(pr.stats, flameprof.get_out(svg_file_name))
cpys commented 4 years ago

flameprof==0.4

cpys commented 4 years ago

if r equals ('python3.8/site-packages/urllib3/util/wait.py', 127, 'wait_for_socket'), to equals ('python3.8/site-packages/urllib3/util/wait.py', 114, '_have_working_pll'), then calls[(r, to)] equals (0, 0, 0.0, 0.0)

cyzFC commented 2 years ago

I have the same problem, have you solved it?

maccinza commented 1 year ago

I am facing the same issue. Any solutions or is it a matter of the file not being usable by flameprof?

rudin-jiang commented 1 month ago

same issue...