X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=disk_space_estimator.cpp;h=86e5e877f65aeaad39cd7423cc3c0577ed499a94;hb=ffd68fbfb90242069af957f2a28908f0559f8348;hp=a1961057dc79257f4e1ecdebce95306f803ec507;hpb=65fda6b2dadac691df6214945e0862551a11bd4c;p=nageru diff --git a/disk_space_estimator.cpp b/disk_space_estimator.cpp index a196105..86e5e87 100644 --- a/disk_space_estimator.cpp +++ b/disk_space_estimator.cpp @@ -50,7 +50,12 @@ void DiskSpaceEstimator::report_write(const std::string &filename, uint64_t pts) double bytes_per_second = double(st.st_size - measure_points.front().size) / (pts - measure_points.front().pts) * TIMEBASE; double seconds_left = free_bytes / bytes_per_second; - callback(free_bytes, seconds_left); + + // Only report every second, since updating the UI can be expensive. + if (last_pts_reported == 0 || pts - last_pts_reported >= TIMEBASE) { + callback(free_bytes, seconds_left); + last_pts_reported = pts; + } } measure_points.push_back({ pts, st.st_size });