o
    $iU                     @   s   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d Z	dd Z
dd	 Zd
d Zdd Zdd ZdddZedkrBe  dS dS )    Ntimeit)ray_start_client_serverc                    s*     d fdd}|td|7 }d S )Nr   c                      s      d S N)get rayvaluer   c/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/_private/ray_client_microbenchmark.py	get_small      z&benchmark_get_calls.<locals>.get_smallzclient: get calls)putr   )r	   resultsr   r   r   r   benchmark_get_calls   s   
r   c                    s.    j dd  fdd}|td|7 }d S )Nc                   S      dS Ns   okr   r   r   r   r   small_value   s   z2benchmark_tasks_and_get_batch.<locals>.small_valuec                     s$   fddt dD }  |  dS )Nc                       g | ]}   qS r   remote.0_)r   r   r   
<listcomp>       zLbenchmark_tasks_and_get_batch.<locals>.small_value_batch.<locals>.<listcomp>  r   )ranger   )	submittedr	   r   r   r   small_value_batch   s   
z8benchmark_tasks_and_get_batch.<locals>.small_value_batchzclient: tasks and get batchr   r   )r	   r   r    r   r   r   benchmark_tasks_and_get_batch   s   
r"   c                    s    fdd}|t d|7 }d S )Nc                      s     d d S )Nr   r   r   r	   r   r   	put_small"   r   z&benchmark_put_calls.<locals>.put_smallzclient: put callsr   )r	   r   r%   r   r$   r   benchmark_put_calls!   s   r&   c                    s4   j fdd  fdd}|td|d7 }d S )Nc                     s   t dD ]}  d qd S )Nd   r   )r   r   )r   r$   r   r   do_put_small)   s   z0benchmark_remote_put_calls.<locals>.do_put_smallc                            fddtdD  d S )Nc                    r   r   r   r   )r(   r   r   r   /   r   zGbenchmark_remote_put_calls.<locals>.put_multi_small.<locals>.<listcomp>
   r   r   r   r(   r	   r   r   put_multi_small.       z3benchmark_remote_put_calls.<locals>.put_multi_smallzclient: tasks and put batchr   r!   )r	   r   r-   r   r,   r   benchmark_remote_put_calls(   s   r/   c                    s2   t jdt jd  fdd}|td|d7 }d S )Ni  @)dtypec                      s      d S r   r#   r   arrr	   r   r   	put_large7   r   z&benchmark_put_large.<locals>.put_largezclient: put gigabytesg?)npzerosint64r   )r	   r   r3   r   r1   r   benchmark_put_large4   s   r7   c                    s   j ddG fddd}|    fdd}|td|7 } fdd	}|td
|d7 }|jdd    fdd}|td|d7 }d S )Nr   )num_cpusc                       s(   e Zd Zdd Zdd Z fddZdS )z%benchmark_simple_actor.<locals>.Actorc                 S   r   r   r   selfr   r   r   r   @      z1benchmark_simple_actor.<locals>.Actor.small_valuec                 S   r   r   r   )r:   xr   r   r   small_value_argC   r;   z5benchmark_simple_actor.<locals>.Actor.small_value_argc                    s      fddt|D  d S )Nc                       g | ]} j  qS r   r   r   r   r9   r   r   r   G       zKbenchmark_simple_actor.<locals>.Actor.small_value_batch.<locals>.<listcomp>r+   )r:   nr$   r9   r   r    F   r.   z7benchmark_simple_actor.<locals>.Actor.small_value_batchN)__name__
__module____qualname__r   r=   r    r   r$   r   r   Actor>   s    rE   c                      s     j  d S r   )r   r   r   r   ar	   r   r   
actor_syncK   s   z*benchmark_simple_actor.<locals>.actor_synczclient: 1:1 actor calls syncc                      r)   )Nc                    r>   r   r?   r   rG   r   r   r   Q   r@   z?benchmark_simple_actor.<locals>.actor_async.<locals>.<listcomp>r   r+   r   rF   r   r   actor_asyncP   r.   z+benchmark_simple_actor.<locals>.actor_asynczclient: 1:1 actor calls asyncr      )max_concurrencyc                      r)   )Nc                    r>   r   r?   r   rI   r   r   r   X   r@   zDbenchmark_simple_actor.<locals>.actor_concurrent.<locals>.<listcomp>r   r+   r   rF   r   r   actor_concurrentW   r.   z0benchmark_simple_actor.<locals>.actor_concurrentz"client: 1:1 actor calls concurrent)r   r   options)r	   r   rE   rH   rJ   rM   r   rF   r   benchmark_simple_actor=   s   

rO   c              	      s~   | pg } dt ji d fdd	}ttjt D ]$\}}|ds"qt|d}|||  W d    n1 s7w   Y  q| S )Nlogging_levelc                    sh   ddl m} | ! dd l}| s"|jdi   W d    d S W d    d S 1 s-w   Y  d S )Nr   )disable_client_hookr   )ray._private.client_mode_hookrQ   r	   is_initializedinit)
job_configray_init_kwargsrQ   real_ray
ray_configr   r   ray_connect_handlerb   s   "z!main.<locals>.ray_connect_handler
benchmark_)rZ   r   )	loggingWARNINGinspect
getmemberssysmodulesrB   
startswithr   )r   rZ   nameobjr	   r   rX   r   main]   s   
	
re   __main__r   )r^   r\   r`   numpyr4   'ray._private.ray_microbenchmark_helpersr   "ray.util.client.ray_client_helpersr   r   r"   r&   r/   r7   rO   re   rB   r   r   r   r   <module>   s     		
 
