File: //usr/lib/python3/dist-packages/mercurial/__pycache__/statprof.cpython-310.pyc
o
�]Lb�� � @ s� d Z ddlmZmZmZ ddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlmZ ddlmZmZ ejZejZg d�Zh d�Zd d
� ZG dd� de�Ze� ZG d
d� de�ZG dd� de�Zdd� Ze
�� Zdd� Z dd� Z!da"dDdd�Z#dd� Z$dd� Z%dd � Z&dEd!d"�Z'ed#d$� �Z(G d%d&� d&e�Z)G d'd(� d(�Z*dFd*d+�Z+d,d-� Z,d.d/� Z-dEd0d1�Z.dGd3d4�Z/dHd5d6�Z0i Z1d7d8� Z2d9d:� Z3dId=d>�Z4d?d@� Z5dEdAdB�Z6e7dCkr�e�8e6� � dS dS )Ja�
statprof is intended to be a fairly simple statistical profiler for
python. It was ported directly from a statistical profiler for guile,
also named statprof, available from guile-lib [0].
[0] http://wingolog.org/software/guile-lib/statprof/
To start profiling, call statprof.start():
>>> start()
Then run whatever it is that you want to profile, for example:
>>> import test.pystone; test.pystone.pystones()
Then stop the profiling and print out the results:
>>> stop()
>>> display()
% cumulative self
time seconds seconds name
26.72 1.40 0.37 pystone.py:79:Proc0
13.79 0.56 0.19 pystone.py:133:Proc1
13.79 0.19 0.19 pystone.py:208:Proc8
10.34 0.16 0.14 pystone.py:229:Func2
6.90 0.10 0.10 pystone.py:45:__init__
4.31 0.16 0.06 pystone.py:53:copy
...
All of the numerical data is statistically approximate. In the
following column descriptions, and in all of statprof, "time" refers
to execution time (both user and system), not wall clock time.
% time
The percent of the time spent inside the procedure itself (not
counting children).
cumulative seconds
The total number of seconds spent in the procedure, including
children.
self seconds
The total number of seconds spent in the procedure itself (not
counting children).
name
The name of the procedure.
By default statprof keeps the data collected from previous runs. If you
want to clear the collected data, call reset():
>>> reset()
reset() can also be used to change the sampling frequency from the
default of 1000 Hz. For example, to tell statprof to sample 50 times a
second:
>>> reset(50)
This means that statprof will sample the call stack after every 1/50 of
a second of user + system time spent running on behalf of the python
process. When your process is idle (for example, blocking in a read(),
as is the case at the listener), the clock does not advance. For this
reason statprof is not currently not suitable for profiling io-bound
operations.
The profiler uses the hash of the code object itself to identify the
procedures, so it won't confuse different procedures with the same name.
They will show up as two different rows in the output.
Right now the profiler is quite simplistic. I cannot provide
call-graphs or other higher level information. What you see in the
table is pretty much all there is. Patches are welcome :-)
Threading
---------
Because signals only get delivered to the main thread in Python,
statprof only profiles the main thread. However because the time
reporting function uses per-process timers, the results can be
significantly off if other threads' work patterns are not similar to the
main thread's work patterns.
� )�absolute_import�division�print_functionN� )�open)�encoding�pycompat)s starts stops resets displays profile> �
util.py:check�hg.py:<module>�dispatch.py:run�pager.py:pagecmd�color.py:colorcmd�dispatch.py:<lambda>�dispatch.py:dispatch�dispatch.py:_dispatch�dispatch.py:_runcatch�dispatch.py:checkargs�extensions.py:closure�dispatch.py:runcommand�dispatch.py:_runcommand�evolve.py:warnobserrorsc C s t �� } | d | d | d fS )Nr r � )�os�times)r � r �4/usr/lib/python3/dist-packages/mercurial/statprof.py�clock� s r c @ s<