view src/testdir/test_sleep.vim @ 32160:98774a275d6d v9.0.1411

patch 9.0.1411: accuracy of profiling is not optimal Commit: https://github.com/vim/vim/commit/076de79ad832558267b3ff903c048df2f4c1a5d6 Author: Ernie Rael <errael@raelity.com> Date: Thu Mar 16 21:43:15 2023 +0000 patch 9.0.1411: accuracy of profiling is not optimal Problem: Accuracy of profiling is not optimal. Solution: Use CLOCK_MONOTONIC if possible. (Ernie Rael, closes https://github.com/vim/vim/issues/12129)
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Mar 2023 22:45:04 +0100
parents 6d3dee0d7de5
children
line wrap: on
line source

" Test for sleep and sleep! commands

func! s:get_time_ms()
  return float2nr(reltimefloat(reltime()) * 1000)
endfunc

func! s:assert_takes_longer(cmd, time_ms)
  let start = s:get_time_ms()
  execute a:cmd
  let end = s:get_time_ms()
  call assert_true(end - start >=# a:time_ms)
endfun

func! Test_sleep_bang()
  call s:assert_takes_longer('sleep 50m', 50)
  call s:assert_takes_longer('sleep! 50m', 50)
  call s:assert_takes_longer('sl 50m', 50)
  call s:assert_takes_longer('sl! 50m', 50)
  call s:assert_takes_longer('1sleep', 1000)
  call s:assert_takes_longer('normal 1gs', 1000)
endfunc

" vim: shiftwidth=2 sts=2 expandtab