mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-23 03:18:35 +08:00
1c3eecd821
Previously stats_time_start first sampled cpu-time and then real-time, while stats_time_end sampled them in reverse order. This resulted in real-time delta values being possibly a bit smaller than the respective cpu-time deltas, which could become meaningful if the start/end durations are consistently very short and very frequent. In one test case (measuging the time spent at the event loop of a script which spins on zero timeouts), this resulted in accumulated real-time value of ~230ms per second, with a respective cpu-time values of ~500ms. This should not be possible with single thread load. Now start and end sample the values at the same order, so that it balances on average. Each start/end delta now includes overhead of one of each sample type, and excludes one of each sample type on average. With the test case above, it's now 490 +-1 ms for both. (the other 510ms real-time are at the excluded mpv_wait_event calls and the unmeasured-overhead-parts of stats_time_start/end).