
    &`iU                         d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d Z	d Z
d Zd Zd Zd	 Zdd
Zedk    r e             dS dS )    Ntimeit)ray_start_client_serverc                 f                           d           fd}|t          d|          z  }d S )Nr   c                  2                                     d S N)get)rayvalues   z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/ray_client_microbenchmark.py	get_smallz&benchmark_get_calls.<locals>.get_small   s        zclient: get calls)putr   )r
   resultsr   r   s   `  @r   benchmark_get_callsr      sL    GGAJJE      v)9555GGGr   c                 \      j         d              fd}|t          d|          z  }d S )Nc                      dS Ns   ok r   r   r   small_valuez2benchmark_tasks_and_get_batch.<locals>.small_value   s    ur   c                  h    fdt          d          D             }                     |            dS )Nc                 8    g | ]}                                 S r   remote).0_r   s     r   
<listcomp>zLbenchmark_tasks_and_get_batch.<locals>.small_value_batch.<locals>.<listcomp>   s%    ???a[''))???r     r   )ranger	   )	submittedr
   r   s    r   small_value_batchz8benchmark_tasks_and_get_batch.<locals>.small_value_batch   s9    ????5;;???		qr   zclient: tasks and get batchr   r   )r
   r   r!   r   s   `  @r   benchmark_tasks_and_get_batchr#      sY    Z  Z     
 v35FGGGGGGr   c                 8      fd}|t          d|          z  }d S )Nc                  2                          d           d S )Nr   r   r
   s   r   	put_smallz&benchmark_put_calls.<locals>.put_small"   s    




r   zclient: put callsr   )r
   r   r(   s   `  r   benchmark_put_callsr)   !   s7         v)9555GGGr   c                 b      j          fd             fd}|t          d|d          z  }d S )Nc                  V    t          d          D ]}                     d           d S )Nd   r   )r   r   )r   r
   s    r   do_put_smallz0benchmark_remote_put_calls.<locals>.do_put_small)   s3    s 	 	AGGAJJJJ	 	r   c                  d                          fdt          d          D                        d S )Nc                 8    g | ]}                                 S r   r   )r   r   r-   s     r   r   zGbenchmark_remote_put_calls.<locals>.put_multi_small.<locals>.<listcomp>/   s%    :::1$$&&:::r   
   r	   r   )r-   r
   s   r   put_multi_smallz3benchmark_remote_put_calls.<locals>.put_multi_small.   s6    ::::b		:::;;;;;r   zclient: tasks and put batchr   r"   )r
   r   r2   r-   s   `  @r   benchmark_remote_put_callsr3   (   sd    Z    Z< < < < < < v3_dKKKGGGr   c                 ~     t          j        dt           j                   fd}|t          d|d          z  }d S )Ni  @)dtypec                  2                                     d S r   r&   )arrr
   s   r   	put_largez&benchmark_put_large.<locals>.put_large7   s    r   zclient: put gigabytesg?)npzerosint64r   )r
   r   r8   r7   s   `  @r   benchmark_put_larger<   4   sV    
($BH
5
5
5C      v-y'BBBGGGr   c                 r                          d           G  fdd                      }|                                  fd}|t          d|          z  } fd}|t          d|d	          z  }|                    d
                                            fd}|t          d|d	          z  }d S )Nr   )num_cpusc                   &    e Zd Zd Zd Z fdZdS )%benchmark_simple_actor.<locals>.Actorc                     dS r   r   )selfs    r   r   z1benchmark_simple_actor.<locals>.Actor.small_value@       5r   c                     dS r   r   )rB   xs     r   small_value_argz5benchmark_simple_actor.<locals>.Actor.small_value_argC   rC   r   c                 f                           fdt          |          D                        d S )Nc                 B    g | ]}j                                         S r   r   r   )r   r   rB   s     r   r   zKbenchmark_simple_actor.<locals>.Actor.small_value_batch.<locals>.<listcomp>G   s(    AAA1T%,,..AAAr   r1   )rB   nr
   s   ` r   r!   z7benchmark_simple_actor.<locals>.Actor.small_value_batchF   s7    GGAAAAaAAABBBBBr   N)__name__
__module____qualname__r   rF   r!   r'   s   r   Actorr@   >   sS        	 	 		 	 		C 	C 	C 	C 	C 	C 	Cr   rN   c                  `                          j                                                   d S r   )r	   r   r   ar
   s   r   
actor_syncz*benchmark_simple_actor.<locals>.actor_syncK   s)    $$&&'''''r   zclient: 1:1 actor calls syncc                  d                          fdt          d          D                        d S )Nc                 B    g | ]}j                                         S r   rI   r   r   rQ   s     r   r   z?benchmark_simple_actor.<locals>.actor_async.<locals>.<listcomp>Q   '    ===A%%''===r   r   r1   rP   s   r   actor_asyncz+benchmark_simple_actor.<locals>.actor_asyncP   6    ====t===>>>>>r   zclient: 1:1 actor calls asyncr      )max_concurrencyc                  d                          fdt          d          D                        d S )Nc                 B    g | ]}j                                         S r   rI   rU   s     r   r   zDbenchmark_simple_actor.<locals>.actor_concurrent.<locals>.<listcomp>X   rV   r   r   r1   rP   s   r   actor_concurrentz0benchmark_simple_actor.<locals>.actor_concurrentW   rX   r   z"client: 1:1 actor calls concurrent)r   r   options)r
   r   rN   rR   rW   r]   rQ   s   `     @r   benchmark_simple_actorr_   =   s/   ZZZC C C C C C C C C C 	A( ( ( ( ( ( v4jAAAG? ? ? ? ? ? v5{DIIIGb))0022A? ? ? ? ? ? v:<LdSSSGGGr   c                 *   | pg } dt           j        idfd	}t          j        t          j        t                             D ]O\  }}|                    d          st          |          5 } |||            d d d            n# 1 swxY w Y   P| S )Nlogging_levelc                     ddl m}  |            5  dd l}|                                s |j        di  d d d            d S # 1 swxY w Y   d S )Nr   )disable_client_hookr   )ray._private.client_mode_hookrc   r
   is_initializedinit)
job_configray_init_kwargsrc   real_ray
ray_configs       r   ray_connect_handlerz!main.<locals>.ray_connect_handlerb   s    EEEEEE  "" 	, 	,""""**,, ,++
+++		, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   &AA	A	
benchmark_)rk   r   )	loggingWARNINGinspect
getmemberssysmodulesrK   
startswithr   )r   rk   nameobjr
   rj   s        @r   mainrv   ]   s    mG!7?3J, , , , , , 'H(=>>  	c|,, 	$9LMMM 	QTCW	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 Ns   .BB	B	__main__r   )ro   rm   rq   numpyr9   'ray._private.ray_microbenchmark_helpersr   "ray.util.client.ray_client_helpersr   r   r#   r)   r3   r<   r_   rv   rK   r   r   r   <module>r{      s      



     : : : : : : F F F F F F6 6 6
H 
H 
H6 6 6	L 	L 	LC C CT T T@   . zDFFFFF r   