Skip to content

Instantly share code, notes, and snippets.

@tyru
Created Nov 19, 2019
Embed
What would you like to do?
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