- Joined
- Jul 10, 2007
- Messages
- 6,306
private function GetHost takes nothing returns player
call StoreInteger(getTheHost, "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1)
call TriggerSyncStart()
call SyncStoredInteger(getTheHost, "missionKey", "key")
call TriggerSyncReady()
return Player(GetStoredInteger(getTheHost, "missionKey", "key") - 1)
endfunction
JASS:private function GetHost takes nothing returns player call StoreInteger(getTheHost, "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1) call TriggerSyncStart() call SyncStoredInteger(getTheHost, "missionKey", "key") call TriggerSyncReady() return Player(GetStoredInteger(getTheHost, "missionKey", "key") - 1) endfunction
This function was stolen!
Tracks player and computer players through out the game
PTN_GET_PLAYER_COUNT()
include "cj_types.j"
include "cj_typesEx.j"
include "cj_print.j"
include "cj_types_priv.j"
include "cj_typesEx_priv.j"
include "cj_order.j"
include "cj_antibj_base.j"
scope Demo initializer Initialization {
trigger t = CreateTrigger()
event e = TriggerRegisterTimerEvent(t, 0, false)
int sw, i = 5000; float mark
bool Test() {
sw = StopWatchCreate()
do {
if GetPlayerTeam(Player(0)) != -1 {} //.007
//if GetPlayerSlotState(Player(0)) == PLAYER_SLOT_STATE_PLAYING {} //.011
} whilenot --i == 0
mark = StopWatchMark(sw)
StopWatchDestroy(sw)
printf(R2S(mark))
return false
}
void Initialization() {
TriggerAddCondition(t, Condition(function Test))
}
}
Player 4 left.
Player count is 5.
Highest Player number is 6.
scope Tests initializer SetUp
globals
private HandleTable Data
endglobals
private function test takes nothing returns nothing
local timer t
local integer i
call TestHelper.NextInstance()
if TestHelper.IsFinished() then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call Test.Compare()
//call Test.createTable()
return
endif
call Test.Start("PT","GetPlayer")
call GetPlayer(0)
call Test.End()
call Test.Start("Native","Player")
call Player(0)
call Test.End()
endfunction
function TestSC takes nothing returns nothing
call TestHelper.SetTest(170,170)
call TimerStart(CreateTimer(),0.,true,function test)
endfunction
private function SetUp takes nothing returns nothing
set Data = HandleTable.create()
call Test.Declare("PT")
call Test.Declare("Native")
endfunction
endscope
call Test.Start("PT","GetPlayer")
set p = allPlayers[0]
call Test.End()
call Test.Start("Native","Player")
set p = Player(0)
call Test.End()
Ok.
I have redone the test.
Player Tracking is 5% faster than the native
Here is the code I used:
It's inline friendly -.-
vjass just fails now... I haven't seen it inline anything since like 1 version before Zinc...
I guess we wait until Vexorian fixes inlining or we can move to cJASS definitions (which will probably never happen) since they never let you down.
This isn't even doing inline-
JASS:call GetComputerCount()
And that is just this
JASS:constant function GetComputerCount takes nothing returns integer return computerCount endfunction
Inliner is broken atm...
So yea, all code from jasshelper going to be extra slower until vex fixes
But go ahead and continue to blame it on me Malte. I know you love that.
computerCount
// scope Test begins
function Test__hi takes nothing returns nothing
local integer p= GetComputerCount()
a()
endfunction
// scope Test ends
Phase 1: import/novjass/delimited comments
Phase 2: text macros
Phase 3: Zinc
Phase 4: Libraries
Phase 5: Static ifs
Phase 6: Modules
Phase 7: Structs and many other things
Phase 8: PJass
Phase 9: Shadowhelper
Phase 10: PJass
Phase 11: Optimization (inline)
<Your NewGen Installation>\logs\outputWar3Map.j
You can look at the generated map script by going toCode:<Your NewGen Installation>\logs\outputWar3Map.j
My benchmark was not broken.
call Test.Start("PT","GetPlayer")
call GetPlayer(0)
call Test.End()
call Test.Start("Native","Player")
call Player(0)
call Test.End()
Please read!Yes it was. Look here.
JASS:call Test.Start("PT","GetPlayer") call GetPlayer(0) call Test.End() call Test.Start("Native","Player") call Player(0) call Test.End()
First flaw: those are not in separate functions called via TriggerExecute. Which means you can get weird results.
Second flaw: you call Player and GetPlayer, which means GetPlayer cannot inline like it should. So, GetPlayer should be even faster than your benchmark says it is.
Please read!
I directly inlined the GetPlayer function and the test.Start is just a synonym for StopWatchMark()
call Test.Start("PT","GetPlayer")
set p = allPlayers[0]
call Test.End()
call Test.Start("Native","Player")
set p = Player(0)
call Test.End()
MapperMalte said:JASS:scope Tests initializer SetUp globals private HandleTable Data endglobals private function test takes nothing returns nothing local timer t local integer i call TestHelper.NextInstance() if TestHelper.IsFinished() then call PauseTimer(GetExpiredTimer()) call DestroyTimer(GetExpiredTimer()) call Test.Compare() //call Test.createTable() return endif call Test.Start("PT","GetPlayer") call GetPlayer(0) call Test.End() call Test.Start("Native","Player") call Player(0) call Test.End() endfunction function TestSC takes nothing returns nothing call TestHelper.SetTest(170,170) call TimerStart(CreateTimer(),0.,true,function test) endfunction private function SetUp takes nothing returns nothing set Data = HandleTable.create() call Test.Declare("PT") call Test.Declare("Native") endfunction endscope