Lessc execution quite slow

138 views
Skip to first unread message

Ernst de Haan

unread,
Aug 21, 2009, 6:22:41 AM8/21/09
to LESS - Leaner CSS
It seems the 'lessc' script is quite slow, due to a fairly large
overhead. Is anyone else experiencing this slowness? Any suggestions
for improving it, for example by somehow processing multiple files at
once?

This is the output I get from my custom Ant task:

[lesscss] Transforming from /Users/ernst/xxx/build/htdocs to /Users/
ernst/xxx/htdocs.
[lesscss] Transformed "BasicSettings.less" in 902 ms.
[lesscss] Transformed "page-IE6.less" in 866 ms.
[lesscss] Transformed "screen-END_USER.less" in 1839 ms.
[lesscss] Transformed "screen-SiteIntro.less" in 1047 ms.
[lesscss] Transformed "screen-main.less" in 1255 ms.
[lesscss] Transformed "screen-msie7.less" in 819 ms.
[lesscss] Transformed "screen-outside-END_USER.less" in 1009 ms.
[lesscss] 7 file(s) transformed in 7741 ms.

Being concerned about the time spent processing the .less files, I
started to investigate. It turned out the overhead on my machine is
about 800 ms, as witnessed by this test:

$ time lessc -v
lessc 1.1.13

real 0m0.790s
user 0m0.738s
sys 0m0.048s

This is on an Intel Core 2 Duo 2.16 GHz (MacBook Pro) running OS X
10.5.8. Not the slowest machine, I'd say.

Compare this to the overhead of starting 'gem':

$ time gem -v
1.0.1

real 0m0.074s
user 0m0.057s
sys 0m0.015s

Seeing this, it's safe to conclude the overhead is not in Ruby itself.

Since I call lessc on every individual file, the overhead is quickly
becoming a major issue for me, since I've got tens of CSS files, and I
planned to convert most of them to LessCSS over time.

An alternative is to have lessc process multiple files at once, so I
can mitigate the one-time overhead, but this seems not possible at the
moment, at least not for a Ruby-clueless like me.

Suggestions are welcomed!

Cheers,


Ernst

Tigraine

unread,
Aug 25, 2009, 9:34:58 AM8/25/09
to LESS - Leaner CSS
I'm not sure if this is of any help to you,
But while testing IronLess I found that Less spends most of my cycles
loading up and initializing Ruby libraries (Treetop etc).
So if you could change the lessc script to require less only once and
then run the execution multiple times (if processing multiple files)
you should see a performance improvement..

I guess you could look into the lessc file for pointers.. (/gems/
less-1.1.13/bin/lessc). The last statement executes the less
compilation.

greetings Daniel

Ernst de Haan

unread,
Aug 25, 2009, 9:42:13 AM8/25/09
to Tigraine, LESS - Leaner CSS
Daniel,


Thanks for the suggestion. I may indeed try that myself, but I was hoping someone with actual Ruby experience would step in and do something like that. :-)

But meanwhile I'm trying to use plessc from my Ant task wrapper, because it offers greater performance and it's always good to have choice anyway. So my task will support both lessc and plessc.

Cheers,


Ernst
 
Reply all
Reply to author
Forward
0 new messages