Works well with measuring time elapsed. The demonstrate by extending the example, it can be done like this:
start = Time.now
for i in range(0, 10000000)
x = 1 / 100.0
end
duration = Time.now - start
live_loop :tick, delay: duration + 0.5 do
sample :elec_plip, rate: 2
sleep 1
end