mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Add clock api (#3595)
This commit is contained in:
parent
26c0a865db
commit
bed0d306ff
34
autoload/SpaceVim/api/clock.vim
Normal file
34
autoload/SpaceVim/api/clock.vim
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"=============================================================================
|
||||||
|
" clock.vim --- clock API
|
||||||
|
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||||
|
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||||
|
" URL: https://spacevim.org
|
||||||
|
" License: GPLv3
|
||||||
|
"=============================================================================
|
||||||
|
let s:self = {}
|
||||||
|
let s:self.__begin = 0
|
||||||
|
let s:self.__long = 0
|
||||||
|
|
||||||
|
function! s:self.start() abort
|
||||||
|
let self.__begin = reltime()
|
||||||
|
let self.__long = 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:self.pause() abort
|
||||||
|
let self.__long = reltimefloat(reltime(self.__begin))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:self.continue() abort
|
||||||
|
let self.__begin = reltime()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:self.end() abort
|
||||||
|
let self.__end = reltimefloat(reltime(self.__begin))
|
||||||
|
return self.__end + self.__long
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! SpaceVim#api#clock#get() abort
|
||||||
|
return deepcopy(s:self)
|
||||||
|
endfunction
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user