Current File : //proc/self/root/usr/local/lib/python3.6/site-packages/ptrace/__pycache__/profiler.cpython-36.pyc
3

�d��@sPddlmZddlmZddlmZddlZdd�Ze�iddddfd
d�Z	dS)
�)�Profile)�unlink)�StringIONcCsD|dkr@t�}g}x t|�D]}|j|jd��qWt|�|SdS)zD
    https://docs.python.org/3/library/profile.html#calibration
    ri'N)r�range�append�	calibrate�sum)�n�prZmagics�i�r�8/tmp/pip-build-in2aja_b/python-ptrace/ptrace/profiler.pyrsrT��timecCs�d}tt|�d�}	z�|jd�|	j|f|�|�}
|jd�|	j|�tj|	�}|j�|j	|�|jd�t
�}||_|j|�|j
d�x|D]}
|j|
j��q�W|
St|�XdS)zU
    Run a function in a profiler and then display the functions sorted by time.
    z
/tmp/profiler)ZbiaszRun profilerzProfiler: Process data...zProfiler: Result:rN)rr�warningZruncall�errorZ
dump_stats�pstatsZStatsZ
strip_dirsZ
sort_statsr�streamZprint_stats�seek�rstripr)�logger�func�args�kw�verboseZnb_funcZsort_byZnb_calZprofile_filenameZprof�result�stat�log�linerrr
�runProfilers&








r)r)
Zprofiler�osr�iorrr�tuplerrrrr
�<module>s