
    i~                     D    S SK r S SKJr  S qSqSq " S S\5      rSS jrg)    Nc                   *    \ rS rSrSrS rS rS rSrg)ProfilerOptions   aq  
Use a string to initialize a ProfilerOptions.
The string should be in the format: "key1=value1;key2=value;key3=value3".
For example:
  "profile_path=model.profile"
  "batch_range=[50, 60]; profile_path=model.profile"
  "batch_range=[50, 60]; tracer_option=OpDetail; profile_path=model.profile"

ProfilerOptions supports following key-value pair:
  batch_range      - a integer list, e.g. [100, 110].
  state            - a string, the optional values are 'CPU', 'GPU' or 'All'.
  sorted_key       - a string, the optional values are 'calls', 'total',
                     'max', 'min' or 'ave.
  tracer_option    - a string, the optional values are 'Default', 'OpDetail',
                     'AllOpDetail'.
  profile_path     - a string, the path to save the serialized profile data,
                     which can be used to generate a timeline.
  exit_on_finished - a boolean.
c                 v    [        U[        5      (       d   eSS/SSSSSSS.U l        U R                  U5        g )	N
      AlltotalDefaultz/tmp/profileT)batch_rangestate
sorted_keytracer_optionprofile_pathexit_on_finished
timer_only)
isinstancestr_options_parse_from_string)selfoptions_strs     ^/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddleocr/ppocr/utils/profiler.py__init__ProfilerOptions.__init__0   sI    +s++++ 8!&* $
 	,    c                 6   UR                  SS5      R                  S5       H  nUR                  S5      u  p4US:X  a  UR                  SS5      R                  SS5      R                  S5      n[        [        [        U5      5      n[        U5      S	:  a)  US
   S
:  a  US   US
   :  a  XPR                  U'   M  M  M  M  US:X  a"  UR                  5       S;   U R                  U'   M  US;   a  X@R                  U'   M  US:X  d  M  X@R                  U'   M     g )N  ;=r   [],   r      r   )yestruet1)r   r   r   r   r   )replacesplitlistmapintlenr   lower)r   r   kvkeyvalue
value_lists         r   r   "ProfilerOptions._parse_from_string>   s   %%c2.44S9B#JCm#"]]33;;CDJJ3O
!#c:"67

Oq("1*"1
15)3MM#& 6 + )
 **%*[[]6O%Oc"PP%*c"$%*c"! :r   c                 v    U R                   R                  US 5      c  [        SU-  5      eU R                   U   $ )Nz1ProfilerOptions does not have an option named %s.)r   get
ValueError)r   names     r   __getitem__ProfilerOptions.__getitem__Q   s:    ==T4(0PSWWXX}}T""r   )r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r;   __static_attributes__ r   r   r   r      s    (-+&#r   r   c                 $   U c  g[         c  [        U 5      q [        cs  [        [         S   5      [        S5      :H  n[        R
                  " [         S   S   [         S   S   4[        R                  " S5      US9q[        R                  5         O[        R                  5         [        [         S   S   :X  aO  [        R                  5         [        R                  SS	S
S9  Sq[         S   (       a  [        R                  " S5        [        S-  q	g)aK  
Enable the operator-level timing using PaddlePaddle's profiler.
The profiler uses a independent variable to count the profiler steps.
One call of this function is treated as a profiler step.
Args:
  profiler_options - a string to initialize the ProfilerOptions.
                     Default is None, and the profiler is disabled.
Nr   Tr   r   r&   z./profiler_log)	scheduleron_trace_readyr   Fms)	op_detail
thread_sep	time_unitr   )_profiler_optionsr   _profr   profilerProfilerexport_chrome_tracingstartstep_profiler_step_idstopsummarysysexit)r   _timer_onlys     r   add_profiler_steprX   W   s       +K8
 }+L9:c$iG!!!-03!-03 $99:JK"
 	

-m<Q??

$G/0HHQKr   )N)	rU   paddle.profilerrM   rR   rK   rL   objectr   rX   rC   r   r   <module>r[      s4     "    9#f 9#x+r   