Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/cherrypy/lib/__pycache__/profiler.cpython-39.pyc
Ðазад
a v�h� � @ s� d Z ddlZddlZddlZddlZddlZddlZz"ddlZddlZdd� Z e e_ W n eyp dZdZY n0 daG dd� de �ZG dd� de�ZG d d � d �Zddd �Zedkr�eeejdd� �� dS )ai Profiler tools for CherryPy. CherryPy users ============== You can profile any of your pages as follows:: from cherrypy.lib import profiler class Root: p = profiler.Profiler("/path/to/profile/dir") @cherrypy.expose def index(self): self.p.run(self._index) def _index(self): return "Hello, world!" cherrypy.tree.mount(Root()) You can also turn on profiling for all requests using the ``make_app`` function as WSGI middleware. CherryPy developers =================== This module can be used whenever you make changes to CherryPy, to get a quick sanity-check on overall CP performance. Use the ``--profile`` flag when running the test suite. Then, use the ``serve()`` function to browse the results in a web browser. If you run this module from the command line, it will call ``serve()`` for you. � Nc C sL | \}}}|� d�r:tj�|dd� �|dd� ||fS tj�|�||fS )zQMake profiler output more readable by adding `__init__` modules' parents z__init__.pyNi�)�endswith�os�path�basename)� func_name�filename�line�name� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/cherrypy/lib/profiler.py�new_func_strip_path1 s �r c @ sZ e Zd Zddd�Zdd� Zdd� Zdd d �Zejdd� �Z ejd d� �Z ejdd� �ZdS )�ProfilerNc C s: |st j�t j�t�d�}|| _t j�|�s6t �|� d S )N�profile)r r �join�dirname�__file__�exists�makedirs��selfr r r r �__init__H s zProfiler.__init__c O sN t d }a tj�| jd| �}t�� }|j|g|�R i |��}|�|� |S )z!Dump profile data into self.path.� �cp_%04d.prof)�_countr r r r �Profile�runcall� dump_stats)r �func�args�params�cr Zprof�resultr r r �runO s zProfiler.runc C s dd� t �| j�D �S )z,:rtype: list of available profiles. c S s$ g | ]}|� d �r|�d�r|�qS )Zcp_z.prof)� startswithr )�.0�fr r r � <listcomp>\ s �z&Profiler.statfiles.<locals>.<listcomp>)r �listdirr �r r r r � statfilesY s zProfiler.statfiles� cumulativec C s� t �� }tjdkrHtjtj�| j|�|d�}|� � |� |� |�� nPt�tj�| j|��}|� � |� |� tj}z|t_|�� W |t_n|t_0 |� � }|�� |S )zL:rtype stats(index): output of print_stats() for the given profile. )� � )�stream)�io�StringIO�sys�version_info�pstatsZStatsr r r Z strip_dirsZ sort_statsZprint_stats�stdout�getvalue�close)r r Zsortby�sio�sZoldout�responser r r �stats_ s"