B
    Ò»ˆd  ã               @   s0   d Z ddlZG dd„ deƒZG dd„ deƒZdS )z9Data structures and algorithms for profiling information.é    Nc               @   s$   e Zd ZdZdd„ Zedd„ ƒZdS )ÚProfileDatumzProfile data point.c             C   sp   || _ || _|| _|| _|| _| jrDdtj | j¡| j| jf | _nd| _|| _	| jj
| _| jj| jj | _dS )ap  Constructor.

    Args:
      device_name: (string) name of the device.
      node_exec_stats: `NodeExecStats` proto.
      file_path: path to the source file involved in creating the op.
      line_number: line number in the file involved in creating the op.
      func_name: name of the function that the line belongs to.
      op_type: (string) Operation type.
    z	%s:%d(%s)Ú N)Údevice_nameÚnode_exec_statsÚ	file_pathÚline_numberÚ	func_nameÚosÚpathÚbasenameZfile_line_funcÚop_typeZall_start_microsÚ
start_timeZop_end_rel_microsZop_start_rel_microsÚop_time)Úselfr   r   r   r   r   r   © r   úW/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/debug/lib/profiling.pyÚ__init__   s    
zProfileDatum.__init__c             C   s   | j jS )z0Op execution time plus pre- and post-processing.)r   Zall_end_rel_micros)r   r   r   r   Ú	exec_time7   s    zProfileDatum.exec_timeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r   r      s    r   c               @   s8   e Zd ZdZdd„ Zdd„ Zedd„ ƒZedd	„ ƒZd
S )ÚAggregateProfilez>Profile summary data for aggregating a number of ProfileDatum.c             C   s0   |j | _|j| _d|j|jjf }|di| _dS )zˆConstructor.

    Args:
      profile_datum: (`ProfileDatum`) an instance of `ProfileDatum` to
        initialize this object with.
    z%s:%sé   N)r   Útotal_op_timer   Útotal_exec_timer   r   Ú	node_nameÚ_node_to_exec_count)r   Úprofile_datumÚdevice_and_noder   r   r   r   @   s
    zAggregateProfile.__init__c             C   sp   |  j |j7  _ |  j|j7  _d|j|jjf }d|j|jjf }|| jkrb| j|  d7  < n
d| j|< dS )z¤Accumulate a new instance of ProfileDatum.

    Args:
      profile_datum: (`ProfileDatum`) an instance of `ProfileDatum` to
        accumulate to this object.
    z%s:%sr   N)r   r   r   r   r   r   r   r   )r   r   r    r   r   r   ÚaddN   s    
zAggregateProfile.addc             C   s
   t | jƒS )N)Úlenr   )r   r   r   r   Ú
node_countb   s    zAggregateProfile.node_countc             C   s   t | j ¡ ƒS )N)Úsumr   Úvalues)r   r   r   r   Únode_exec_countf   s    z AggregateProfile.node_exec_countN)	r   r   r   r   r   r!   r   r#   r&   r   r   r   r   r   =   s
   r   )r   r	   Úobjectr   r   r   r   r   r   Ú<module>   s   )