Fix eta calculations

This commit is contained in:
Starbeamrainbowlabs 2021-02-07 02:45:34 +00:00
parent 2b29334d82
commit a360f06138
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 12 additions and 4 deletions

View file

@ -111,7 +111,11 @@ local function subdivide_step_afterload(state_emerge, state_ours)
end
state_ours.times.steps_total = state_ours.times.steps_total + state_ours.times.step_last
state_ours.times.step_start_abs = wea.get_ms_time()
state_ours.eta = wea.eta(state_ours.times.steps, state_ours.chunks_total)
state_ours.eta = wea.eta(
state_ours.times.steps,
state_ours.chunks_completed,
state_ours.chunks_total
)
if state_ours.chunks_completed > 0 then
state_ours.emerge_overhead = state_ours.times.emerge_total / state_ours.times.steps_total
end

View file

@ -31,12 +31,12 @@ function worldeditadditions.get_ms_time()
return minetest.get_us_time() / 1000
end
function worldeditadditions.eta(existing_times, times_total_count)
function worldeditadditions.eta(existing_times, done_count, total_count)
local max = 100
local average = worldeditadditions.average(
worldeditadditions.table_get_last(existing_times, max)
)
local times_left = times_total_count - math.min(100, #existing_times)
local times_left = total_count - done_count
if times_left == 0 then return 0 end
return average * times_left
end

View file

@ -41,7 +41,11 @@ local function step(params)
((params.i + 1) / params.count)*100,
worldeditadditions.human_time(params.times[#params.times] or 0),
worldeditadditions.human_time(worldeditadditions.average(params.times)),
worldeditadditions.human_time(worldeditadditions.eta(params.times, params.count))
worldeditadditions.human_time(worldeditadditions.eta(
params.times,
params.i,
params.count
))
))
local cmd = minetest.chatcommands[params.cmd_name]