From eeef07d05a7e53de469f19a23fe1e69f569fc924 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 5 Dec 2019 10:14:07 +0100 Subject: Add profiling instructions for advprofiler --- advtrains/path.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'advtrains/path.lua') diff --git a/advtrains/path.lua b/advtrains/path.lua index 825e59b..1e224e4 100644 --- a/advtrains/path.lua +++ b/advtrains/path.lua @@ -156,6 +156,9 @@ function advtrains.path_get(train, index) if index ~= atfloor(index) then error("For train "..train.id..": Called path_get() but index="..index.." is not a round number") end + + advtrains.profiler:enter("path_get") + local pef = train.path_ext_f while index > pef do local pos = train.path[pef] @@ -224,6 +227,8 @@ function advtrains.path_get(train, index) train.path_req_f = index end + advtrains.profiler:leave("path_get") + return train.path[index], (index<=train.path_trk_f and index>=train.path_trk_b) end @@ -257,6 +262,8 @@ function advtrains.path_get_adjacent(train, index) end function advtrains.path_get_index_by_offset(train, index, offset) + advtrains.profiler:enter("path_get_index_by_offset") + local off = offset local idx = atfloor(index) -- go down to floor. Calculate required path_dist @@ -286,6 +293,8 @@ function advtrains.path_get_index_by_offset(train, index, offset) -- we should now be on the floor of the index we actually want. -- give them the rest! + advtrains.profiler:leave("path_get_index_by_offset") + return idx + (off / train.path_dist[idx]) end -- cgit v1.2.3