Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tyru
Created November 19, 2019 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyru/418e198864907e39c94d6afca6cbc040 to your computer and use it in GitHub Desktop.
Save tyru/418e198864907e39c94d6afca6cbc040 to your computer and use it in GitHub Desktop.
Benchmark for parsing SKK dictionary
function! s:run() abort
let skkdict = expand('~/Dropbox/config/skkdict/system-dict')
" for memory cache
call readfile(skkdict)
let start = reltime()
call readfile(skkdict)
let b1 = reltimestr(reltime(start, reltime()))
let start = reltime()
let re = '^(\S\+) /(.*)/'
call map(readfile(skkdict), 'matchlist(v:val, re)')
let b2 = reltimestr(reltime(start, reltime()))
let start = reltime()
function! s:convert(_, line) abort
let l = matchlist(a:line, '^(\S\+) /(.*)/')
if empty(l) | return {} | endif
return #{
\ key: l[1],
\ cands: split(l[2], '/'),
\}
endfunction
call map(readfile(skkdict), function('s:convert'))
let b3 = reltimestr(reltime(start, reltime()))
" b1 = 0.070052
" b2 = 0.818918
" b3 = 1.855558
echom 'b1 =' b1
echom 'b2 =' b2
echom 'b3 =' b3
endfunction
call s:run()
@tyru
Copy link
Author

tyru commented Nov 19, 2019

  機種名:    MacBook Pro
  機種ID:    MacBookPro15,1
  プロセッサ名:    6-Core Intel Core i7
  プロセッサ速度:    2.6 GHz
  プロセッサの個数:    1
  コアの総数:    6
  二次キャッシュ(コア単位):    256 KB
  三次キャッシュ:    12 MB
  ハイパー・スレッディング・テクノロジ:    有効
  メモリ:    16 GB

@tyru
Copy link
Author

tyru commented Nov 19, 2019

$ du -s ~/Dropbox/config/skkdict/system-dict
4388    /Users/tyru/Dropbox/config/skkdict/system-dict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment