vim-logcat
vim-logcat copied to clipboard
Terrible performance for long (JSON) lines
I had some issues opening vim up a 500K-sized file, that contained only 4 lines, 2 of them being very long JSON strings objecst. I enabled VIM profiling and found out this plugin was the cause.
Here's the profile summary:
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
1 204.214577 <SNR>7_DetectLogcat()
4 0.019893 <SNR>59_Highlight_Matching_Pair()
1 0.000886 0.000060 <SNR>47_BufEnterHook()
1 0.000721 0.000193 344()
1 0.000159 0.000032 363()
3 0.000123 syntastic#util#fname2buf()
9 0.000107 0.000070 syntastic#util#var()
1 0.000088 0.000050 302()
1 0.000068 0.000028 <SNR>47_BufWinEnterHook()
1 0.000067 0.000018 <SNR>47_BufReadPostHook()
1 0.000066 0.000008 270()
7 0.000062 0.000047 syntastic#log#debug()
1 0.000054 0.000023 307()
1 0.000048 0.000029 271()
2 0.000046 0.000015 362()
2 0.000046 0.000023 273()
1 0.000045 364()
2 0.000038 0.000012 301()
9 0.000037 syntastic#util#rawVar()
2 0.000031 0.000012 297()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
1 204.214577 <SNR>7_DetectLogcat()
4 0.019893 <SNR>59_Highlight_Matching_Pair()
1 0.000721 0.000193 344()
3 0.000123 syntastic#util#fname2buf()
9 0.000107 0.000070 syntastic#util#var()
1 0.000886 0.000060 <SNR>47_BufEnterHook()
1 0.000088 0.000050 302()
7 0.000062 0.000047 syntastic#log#debug()
1 0.000045 364()
9 0.000037 syntastic#util#rawVar()
1 0.000159 0.000032 363()
1 0.000048 0.000029 271()
1 0.000068 0.000028 <SNR>47_BufWinEnterHook()
1 0.000030 0.000028 365()
1 0.000027 ResetNumbers()
1 0.000026 306()
1 0.000054 0.000023 307()
2 0.000046 0.000023 273()
2 0.000022 syntastic#util#stamp()
1 0.000067 0.000018 <SNR>47_BufReadPostHook()
and details about the logcat function:
FUNCTION <SNR>7_DetectLogcat()
Defined: ~/dotfiles/vim/bundle/vim-logcat/ftdetect/logcat.vim line 1
Called 1 time
Total time: 204.214577
Self time: 204.214577
count total (s) self (s)
" Detect from the 2nd line. The 1st line could be:
" -------- beginning of system
1 204.214568 if line('$') > 1 && getline(2) =~# '.* [F|E|W|I|D|V] .*:.*'
set filetype=logcat
1 0.000001 endif
I don't know what (if anything) can be done about that. The file type check is pretty minimal. Can you try to see if changing the * in RegEx to something like {1,100} speeds things up? Ex:
.{0,100} [F|E|W|I|D|V]\/.{0,100}:.{0,100}
or (maybe a bit too loose):
.{0,100} [F|E|W|I|D|V].{0,100}:.{0,100}
Either one works wonderfully! It's still the slowest function, but very acceptable and not noticeable anymore for the same file:
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
1 0.015169 <SNR>7_DetectLogcat()
1 0.000830 0.000047 <SNR>47_BufEnterHook()
1 0.000694 0.000215 342()
1 0.000132 0.000025 361()
3 0.000099 syntastic#util#fname2buf()
9 0.000089 0.000058 syntastic#util#var()
1 0.000075 0.000036 300()
1 0.000073 0.000008 268()
7 0.000070 0.000057 syntastic#log#debug()
1 0.000068 0.000024 <SNR>47_BufWinEnterHook()
1 0.000059 0.000019 <SNR>47_BufReadPostHook()
1 0.000054 0.000039 269()
1 0.000049 0.000018 305()
1 0.000043 362()
2 0.000038 0.000017 360()
2 0.000037 0.000014 271()
2 0.000034 0.000017 299()
9 0.000031 syntastic#util#rawVar()
1 0.000028 0.000010 272()
1 0.000027 304()