When you enter a chest (depending on the version) the advancement "inventory_changed" either wont get triggered, or wont trigger the correct amount of times. This is what the datapack detects.

All this is doing is forcibly updating the inventory every tick. Then storing the advancement triggers to a scoreboard. Then compare what the number should be to the actual output.

test the lag on your own system for me it added about 1-2 ms.