Last active
January 24, 2019 06:14
-
-
Save ichizok/05b60543e8878716a6d91523d58490e9 to your computer and use it in GitHub Desktop.
measure elapsed time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function s:estimate(n, t) | |
let start = reltime() | |
for _ in range(a:n) | |
execute 'sleep' a:t | |
endfor | |
let elapsed = reltimefloat(reltime(start)) | |
let calibrator = (a:n * a:t * (a:t =~# 'm$' ? 1 : 1000)) / (elapsed * 1000) | |
echo printf('%dx sleep %s', a:n, a:t) | |
echo printf('Elapsed = %f', elapsed) | |
echo printf('Calibration = %f', calibrator) | |
echo '' | |
endfunction | |
sleep 1 | |
call s:estimate(1000, '1m') | |
call s:estimate(100, '10m') | |
call s:estimate(10, '100m') | |
call s:estimate(1, '1') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment