LARG / HFO

Half Field Offense in Robocup 2D Soccer
MIT License
231 stars 93 forks source link

python version hfo.step() is very slow #45

Open liyuanl6666 opened 6 years ago

liyuanl6666 commented 6 years ago

Can you check why the python version hfo.step() is so slow? I'm trying to use the python interface; found that the step() function is much much slower than the C version (with the caffe code): for example, the time used to generate actions with actor network is about 40 seconds (across multiple episodes), and the time to execute hfo.step() is about 50 seconds... this is way much slower than the c++ version.

drallensmith commented 6 years ago

50 seconds for each execution of hfo.step()? That does not accord with my experience. Could you try running some of the Python examples and see how long they're taking per episode (which has multiple invocations of hfo.step(), of course)?

liyuanl6666 commented 6 years ago

42.94 seconds spent on hfo.step() in 2000 plays(each play has roughly 100 steps) While for the c++ version, the code can finish 2000 plays within 32 seconds(not only the time used on hfo.step, but all).

mhauskn commented 6 years ago

In general the python interface is going to be a slower since the native code is c++ and python calling the native c++ through a ctypes interface. Python's call to step is here:

https://github.com/LARG/HFO/blob/master/hfo/hfo.py#L177

and the ctypes implementation is:

https://github.com/LARG/HFO/blob/master/hfo/hfo_c_wrapper.h#L40

I'm not too sure how to further optimize the routine, but if you have ideas, I'd be happy to listen.

On Wed, Sep 20, 2017 at 8:09 PM, liyuanl6666 notifications@github.com wrote:

42.94 seconds spent on hfo.step() in 2000 plays(each play has roughly 100 steps) While for the c++ version, the code can finish 2000 plays within 32 seconds(not only the time used on hfo.step, but all).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LARG/HFO/issues/45#issuecomment-331038512, or mute the thread https://github.com/notifications/unsubscribe-auth/AABNOYRReGkhcHKqCj266MUH1p7m459Wks5skdNWgaJpZM4PeCZz .

drallensmith commented 6 years ago

Also: