Last active
August 29, 2015 14:13
-
-
Save itchyny/21937d6847eb87f6104a to your computer and use it in GitHub Desktop.
profile result of https://gist.github.com/itchyny/8e5f88f9e5c4700ff1d3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FUNCTION <SNR>4_new_strwidthpart_reverse() | |
Called 3843 times | |
Total time: 10.562034 | |
Self time: 9.863578 | |
count total (s) self (s) | |
3843 0.028234 if a:width <= 0 | |
63 0.001507 return '' | |
endif | |
" Split into array | |
3780 4.381157 let strarr = split(a:str, '\zs') | |
3780 0.270479 0.083609 let width = s:wcswidth(a:str) | |
3780 0.040699 let strlen = len(strarr) | |
" Start binary search | |
3780 0.020375 let diff = strlen / 2 | |
3780 0.027083 let leftindex = 0 | |
3780 0.013445 let index = -1 | |
32886 0.184495 while width > a:width && diff | |
29106 0.411092 let index = min([leftindex + diff, strlen]) - 1 | |
29106 2.996260 2.484674 let partwidth = s:wcswidth(join(strarr[(leftindex):(index)], '')) | |
29106 0.271477 if width - partwidth >= a:width || diff <= 1 | |
19656 0.210977 let width -= partwidth | |
19656 0.127308 let leftindex = index + 1 | |
19656 0.047250 endif | |
29106 0.091725 if diff > 1 | |
23751 0.105325 let diff = diff / 2 | |
23751 0.157759 endif | |
29106 0.088385 endwhile | |
3780 0.587081 return index < strlen ? join(strarr[(index + 1):], '') : '' | |
FUNCTION <SNR>4_strwidthpart_reverse() | |
Called 3843 times | |
Total time: 59.031721 | |
Self time: 50.336910 | |
count total (s) self (s) | |
3843 0.019939 if a:width <= 0 | |
63 0.000168 return '' | |
endif | |
3780 0.021779 let ret = a:str | |
3780 0.259746 0.060382 let width = s:wcswidth(a:str) | |
772380 3.781111 while width > a:width | |
768600 16.278451 let char = matchstr(ret, '^.') | |
768600 11.799622 let ret = ret[len(char) :] | |
768600 22.698868 14.203421 let width -= s:wcswidth(char) | |
768600 2.735721 endwhile | |
3780 0.015197 return ret | |
FUNCTION <SNR>4_new_strwidthpart() | |
Called 3843 times | |
Total time: 10.272793 | |
Self time: 9.622317 | |
count total (s) self (s) | |
3843 0.023118 if a:width <= 0 | |
63 0.000167 return '' | |
endif | |
" Split into array | |
3780 4.262276 let strarr = split(a:str, '\zs') | |
3780 0.275712 0.080953 let width = s:wcswidth(a:str) | |
" Start binary search | |
3780 0.031338 let index = len(strarr) | |
3780 0.019846 let diff = index / 2 | |
3780 0.033331 let rightindex = index - 1 | |
32508 0.163413 while width > a:width && diff | |
28728 0.378663 let index = max([rightindex - diff + 1, 0]) | |
28728 2.985590 2.529873 let partwidth = s:wcswidth(join(strarr[(index):(rightindex)], '')) | |
28728 0.268011 if width - partwidth >= a:width || diff <= 1 | |
19782 0.117992 let width -= partwidth | |
19782 0.141968 let rightindex = index - 1 | |
19782 0.048681 endif | |
28728 0.093494 if diff > 1 | |
23562 0.100147 let diff = diff / 2 | |
23562 0.049855 endif | |
28728 0.070989 endwhile | |
3780 0.651851 return index ? join(strarr[:index - 1], '') : '' | |
FUNCTION Test_strwidthpart() | |
Called 1 time | |
Total time: 195.972491 | |
Self time: 1.765382 | |
count total (s) self (s) | |
1 0.000006 let strmin = 0 | |
1 0.000004 let strmax = 300 | |
1 0.000004 let strstep = 5 | |
1 0.000003 let outmin = -10 | |
1 0.000003 let outmax = 300 | |
1 0.000003 let outstep = 5 | |
62 0.000256 for i in range(strmin, strmax, strstep) | |
61 0.000671 let str = repeat('あa', i) | |
3904 0.022893 for j in range(outmin, outmax, outstep) | |
3843 114.442991 0.102430 let out1 = s:P.strwidthpart(str, i) | |
3843 10.961122 0.688329 let out2 = s:P.new_strwidthpart(str, i) | |
3843 0.032616 if out1 !=# out2 | |
call Error_strwidthpart() | |
endif | |
3843 59.126255 0.094534 let out1 = s:P.strwidthpart_reverse(str, i) | |
3843 11.257802 0.695768 let out2 = s:P.new_strwidthpart_reverse(str, i) | |
3843 0.029949 if out1 !=# out2 | |
call Error_strwidthpart() | |
endif | |
3843 0.009382 endfor | |
61 0.000112 endfor | |
FUNCTION <SNR>4_strwidthpart() | |
Called 3843 times | |
Total time: 114.340561 | |
Self time: 105.334140 | |
count total (s) self (s) | |
3843 0.021707 if a:width <= 0 | |
63 0.000162 return '' | |
endif | |
3780 0.022978 let ret = a:str | |
3780 0.288444 0.061628 let width = s:wcswidth(a:str) | |
773640 3.924480 while width > a:width | |
769860 69.921682 let char = matchstr(ret, '.$') | |
769860 12.728451 let ret = ret[: -1 - len(char)] | |
769860 22.997894 14.218289 let width -= s:wcswidth(char) | |
769860 2.938713 endwhile | |
3780 0.056247 return ret | |
FUNCTIONS SORTED ON TOTAL TIME | |
count total (s) self (s) function | |
1 195.972491 1.765382 Test_strwidthpart() | |
3843 114.340561 105.334140 <SNR>4_strwidthpart() | |
3843 59.031721 50.336910 <SNR>4_strwidthpart_reverse() | |
3843 10.562034 9.863578 <SNR>4_new_strwidthpart_reverse() | |
3843 10.272793 9.622317 <SNR>4_new_strwidthpart() | |
FUNCTIONS SORTED ON SELF TIME | |
count total (s) self (s) function | |
3843 114.340561 105.334140 <SNR>4_strwidthpart() | |
3843 59.031721 50.336910 <SNR>4_strwidthpart_reverse() | |
3843 10.562034 9.863578 <SNR>4_new_strwidthpart_reverse() | |
3843 10.272793 9.622317 <SNR>4_new_strwidthpart() | |
1 195.972491 1.765382 Test_strwidthpart() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment