| 07-10-2008, 04:27 PM | #1 |
Does anyone have a time measurement of: (TriggerEvaluate on an empty Condition) / (TriggerExecute on an empty Action) JASS://=========================================================================== private function Actions takes nothing returns nothing endfunction //=========================================================================== private function Conditions takes nothing returns boolean return false endfunction |
| 07-10-2008, 05:12 PM | #2 |
I think vex said TriggerExecute was faster, i don't know the statistics though. Why does it matter anyways when they both do completely different things? |
| 07-10-2008, 05:23 PM | #3 | |
Quote:
@cohadar: Isn't there a StopTimer function people are using to measure function call speeds, I think Strilanc has one, the one he used to measure his DUI. |
| 07-10-2008, 05:48 PM | #4 |
I had a benchmark with Evaluate Execute and ExecuteFunc, but I can't find it, tried google and all. |
| 07-10-2008, 06:22 PM | #5 | |
Quote:
Please (someone) make benchmark again, I cannot use grimoire japi it always crashes my game. EDIT: And by the way TriggerEvaluate is faster I just want to know how much faster. |
| 07-10-2008, 06:28 PM | #6 |
If you write it up and post it here, I'll run it. |
| 07-10-2008, 06:30 PM | #7 | |||
JASS:scope A initializer init globals private timer t = CreateTimer() private integer j = 0 endglobals private function Actions takes nothing returns nothing endfunction private function Conditions takes nothing returns boolean return false endfunction private function TestExecuteFunc takes nothing returns nothing local integer sw = StopWatchCreate() local integer i = 0 loop exitwhen i==1000 call ExecuteFunc(SCOPE_PRIVATE+"Actions") set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 600 then call PauseTimer(t) call BJDebugMsg("Done") endif endfunction private function TestExecute takes nothing returns nothing local integer sw = StopWatchCreate() local integer i = 0 loop exitwhen i==1000 call Actions.execute() set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 400 then call DebugPrint("=========="+" EXECUTE FUNC "+"==========") call TimerStart(t, 0.1, true, function TestExecuteFunc) endif endfunction private function TestEvaluate takes nothing returns nothing local integer sw = StopWatchCreate() local integer i = 0 loop exitwhen i==1000 call Conditions.evaluate() set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 200 then call DebugPrint("=========="+" EXECUTE "+"==========") call TimerStart(t, 0.1, true, function TestExecute) endif endfunction private function init takes nothing returns nothing call DebugPrint("=========="+" EVALUATE "+"==========") call TimerStart(t, 0.1, true, function TestEvaluate) endfunction endscope
Edited because: Added ExecuteFunc. |
| 07-10-2008, 06:34 PM | #8 |
Oh. One upped by Alex yet again. |
| 07-10-2008, 06:56 PM | #9 |
You should have included an empty loop in the benchmark, right now we have no idea what the relative difference between the methods is. Also, you should put the integer i declaration before creating the stopwatch, although it probably doesn't have much effect since you loop one thousand times; besides, benchmarking an empty loop would take the i declaration into account too. |
| 07-10-2008, 07:12 PM | #10 | |||||||||||||||||||||
JASS:scope A initializer init globals private timer t = CreateTimer() private integer j = 0 private trigger trig = CreateTrigger() endglobals //=========================================================================== private function Actions takes nothing returns nothing endfunction private function Conditions takes nothing returns boolean return false endfunction //=========================================================================== private function TestEmpty takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 1400 then call PauseTimer(t) call BJDebugMsg("Done") endif endfunction private function TestCall takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call Actions() set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 1200 then call DebugPrint("=========="+" EMPTY LOOP "+"==========") call TimerStart(t, 0.1, true, function TestEmpty) endif endfunction private function TestExecuteFunc takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call ExecuteFunc(SCOPE_PRIVATE+"Actions") set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 1000 then call DebugPrint("=========="+" CALL "+"==========") call TimerStart(t, 0.1, true, function TestCall) endif endfunction private function TestTriggerExecute takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call TriggerExecute(trig) set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 800 then call DebugPrint("=========="+" EXECUTE FUNC "+"==========") call TimerStart(t, 0.1, true, function TestExecuteFunc) endif endfunction private function TestTriggerEvaluate takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call TriggerEvaluate(trig) set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 600 then call DebugPrint("=========="+" TRIGGER EXECUTE "+"==========") call TimerStart(t, 0.1, true, function TestTriggerExecute) endif endfunction private function TestExecute takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call Actions.execute() set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 400 then call DebugPrint("=========="+" TRIGGER EVALUATE "+"==========") call TimerStart(t, 0.1, true, function TestTriggerEvaluate) endif endfunction private function TestEvaluate takes nothing returns nothing local integer i = 0 local integer sw = StopWatchCreate() loop exitwhen i==1000 call Conditions.evaluate() set i = i+1 endloop call DebugPrint(R2S(StopWatchMark(sw)*1000)) call StopWatchDestroy(sw) set j = j+1 if j >= 200 then call DebugPrint("=========="+" EXECUTE "+"==========") call TimerStart(t, 0.1, true, function TestExecute) endif endfunction //=========================================================================== private function init takes nothing returns nothing call TriggerAddAction(trig, function Actions) call TriggerAddCondition(trig, Condition(function Conditions)) call DebugPrint("=========="+" EVALUATE "+"==========") call TimerStart(t, 0.1, true, function TestEvaluate) endfunction endscope
Even with 200*1000 executions there seems to be a fair amount of error. Will need to test multiple times for more accurate results. |
| 07-10-2008, 07:13 PM | #11 |
.evaluate() and .execute() are different to TriggerExecute and TriggerEvaluate. |
| 07-10-2008, 07:46 PM | #12 |
I can't read. ...OK, updated. |
| 07-10-2008, 10:23 PM | #13 |
Someone please give some rep to Alexander244 in my name, I can't atm. And the results are wow, I had no idea (evaluate/execute) ration is so close to 1. I was expecting execute to be like 5 times heavier considering that it needs to create new thread and all.... Maybe jass virtual machine threads don't work like C++ threads, maybe it is a stupid as: set preemptive = true hahaha EDIT: Hay alexander how about you test a boolexpr that points to a function. Something like if boolexpr_var then endif |
| 07-11-2008, 12:08 AM | #14 | ||
Quote:
Quote:
|
| 07-11-2008, 12:43 AM | #15 | |
Quote:
They are preemptive == they are threads. How they are implemented is irrelevant. I sure hope to see some more test results since Vex seems to disagree with current ones. |
