call vs c_func/c_proc with asm
- Posted by Daniel Kluss <codepilot at gmail.com> Dec 28, 2005
- 456 views
this is just a simple speed test it gets the time for a for_loop and subtracts it from the rest as you can see c_proc takes about 10x as long as call one thing that I noticed though is that recursively calling a euphoria function back from assembly (thought the call_back(routine_id("function_name))) works very well when the assembly was called with c_proc/c_func but when called with call it just failed miserably for no reason. speed test these two with atom rv commented out it takes 0.48 seconds for call, but with rv not commented out it takes 1.61 seconds. Hmmm, rv isn't even used for anything Dan
include machine.e include dll.e constant ret=allocate_string({#C3}), ret_=define_c_proc({},ret,{}) atom t,a,at--,rv procedure eret() end procedure constant eret_=routine_id("eret") a=0 t=time() for i = 1 to 100000000 do a+=1 end for ? time()-t at=time()-t--0.91 a=0 t=time() for i = 1 to 100000000 do a+=1 call(ret) end for ? time()-t-at--0.48 a=0 t=time() for i = 1 to 100000000 do a+=1 c_proc(ret_,{}) end for ? time()-t-at--4.21 a=0 t=time() for i = 1 to 100000000 do a+=1 eret() end for ? time()-t-at--2.2 a=0 t=time() for i = 1 to 100000000 do a+=1 call_proc(eret_,{}) end for ? time()-t-at--4.04 ? 1/0
include machine.e include dll.e constant ret=allocate_string({#C3}), ret_=define_c_proc({},ret,{}) atom t,a,at,rv procedure eret() end procedure constant eret_=routine_id("eret") a=0 t=time() for i = 1 to 100000000 do a+=1 end for ? time()-t at=time()-t--0.91 a=0 t=time() for i = 1 to 100000000 do a+=1 call(ret) end for ? time()-t-at--0.48 a=0 t=time() for i = 1 to 100000000 do a+=1 c_proc(ret_,{}) end for ? time()-t-at--4.21 a=0 t=time() for i = 1 to 100000000 do a+=1 eret() end for ? time()-t-at--2.2 a=0 t=time() for i = 1 to 100000000 do a+=1 call_proc(eret_,{}) end for ? time()-t-at--4.04 ? 1/0