-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very slow. #3
Comments
I can confirm this, 8 seconds to bootup for me:
|
+1, I like this & I want it to be faster. Is there a way to get it to load only on CSS files? (It makes all files slow for me) Is there a way to get it to show the document, then color it? |
Same here on my notebook. Up to 10~15 seconds to load. |
Same here. I see a pretty significant CPU spike when loading the plugin.
|
After some digging, helped in part by @ap's refactoring, I narrowed down the performance issue. This only applies to 256-color terminal vim, not mvim or presumably gvim. Since mvim can handle direct hex values for colors, no translation is needed and everything loads quickly. For 256-color terminals, however, the The best solution I can think of is pre-computing the xterm color codes, and altering |
this looks promising. On 18 May 2011 17:20, aniero <
|
It’s |
Since the problem only lies with 256 color terminal users, maybe we can define a set of ranges of colors that translate to one of the 256 colors available rather than pre-calculating all 24 million colors. |
Any of the 24 million colours may show up in a CSS file so it’s necessary to be able to map any of them down to an xterm colour. But it’s not necessary to blindly scan the whole 256-colour table each and every time. I’m thinking along the lines that locating the closest spot inside the 6×6×6 RGB cube provided by xterm should require no more than 6+6+6 iterations at worst. That’s more than a 10-fold speed-up. I’m just trying to convince myself that the results this produces are equivalent to the geometric distance scan the script currently uses. (The colour space in the terminal is so limited that there isn’t room for suboptimal choices.) In the meantime, my fork has a commit that speeds up |
@ap, you're right, I put in the wrong method. It is indeed Agreed with the 1/2-1/3 speedup as well, that dropped my load time to about 2.75 seconds. While I'm all for a faster function, in any case! |
Try now. (And sorry for rebasing like a rabid hound.) It should be 5× faster than the original. It still uses the geometric distance scan, but instead of including the entire colour cube in that scan it picks a single colour from it in constant time. So instead of up to 256 iterations, the loop runs at most 41. I’m still trying to come up with another algorithm for the matching. It should be possible to make it at least 5× faster still. It seems quite unnecessary to scan at all, there should be a data structure that allows picking a colour very much quicker. And so far it’s all start-up time optimisation. There are other small inefficiencies that won’t yield much speed, but they should still help make it more responsive. (Plus, they’d benefit all users, not just console Vimmers.) |
Well, I think you definitely lost me =) On 18 May 2011 23:43, ap <
|
Nice work, the startup time in console vim is sub-second now, down from 4.7 seconds (using @ap's fork)
|
OK everyone, try fetching from me again. The GUI version is now over twice as fast as it was before, and the console version is only slower than the GUI by 40% or so. Start-up time for the console version is almost 20× faster than when I started. At this point it boots so fast and is so responsive that I consider myself done with it. |
Thanks a lot. I'll be pulling this soon. |
Awesome, it's down to a third of a second for console vim and .08 sec for mvim. Nice work, thanks! |
Ok, forgive my foolishness, but its simples doesn't work for me. I put the css.vim archive in ~/.vim/after/syntax/css.vim, open my CSS file in Vim, write my colors but nothing happens. Am I doing anything wrong? Am I NOT doing something important? |
That should be all that’s required. What does |
runtimepath= As usual. |
Check the output of But if the regular |
Awesome speed! Nice work ap! |
Any reason this was never pulled? |
maybe there should be an option to only activate on demand, not when opening any css/html file |
When I run vim with the --startuptime flag, the log printed out says that css-color is taking 4.5 seconds (!!!) to load.
4561.555: sourcing /home/andrew/.vim/bundle-autoupdate/vim-css-color/after/syntax/css.vim
The text was updated successfully, but these errors were encountered: