【Ray版本和类库】2.5.1
【代码】
package ray;
import io.ray.api.ActorHandle;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import java.io.Serializable;
public class SpeedTest {
public static class Actor implements Serializable {
public static long test(long sendTime) {
long time = System.currentTimeMillis() - sendTime;
System.out.println("take time:" + time);
return time;
}
public long actorTest(long sendTime) {
long time = System.currentTimeMillis() - sendTime;
System.out.println("take time:" + time);
return time;
}
}
static void testActorSpeed() throws Exception {
ObjectRef<Long> ref = Ray.task(Actor::test, System.currentTimeMillis()).setResource("CPU", 1.0).remote();
long getSumPvStartMills1 = System.currentTimeMillis();
long time = ref.get();
System.out.println("common task receive took time: ms " + time + " get takes time " + (System.currentTimeMillis() - getSumPvStartMills1));
ActorHandle<Actor> handle = Ray.actor(Actor::new).remote();
ObjectRef<Long> actorRef = handle.task(Actor::actorTest, System.currentTimeMillis()).remote();
long t1 = System.currentTimeMillis();
long actorTime = actorRef.get();
System.out.println("actor task receive took time: ms " + actorTime + " get takes time " + (System.currentTimeMillis() - t1));
}
public static void main(String[] args) throws Exception {
// Intialize Ray runtime.
Ray.init();
testActorSpeed();
}
}
相关截图/链接/日志/监控等信息
Tailing logs until the job exits (disable with --no-wait):
Listening for transport dt_socket at address: 52000
common task receive took time: ms 1676 get takes time 1653
actor task receive took time: ms 1653 get takes time 1659
Ray.get()需要耗时1s多是正常的吗