jsmacro icon indicating copy to clipboard operation
jsmacro copied to clipboard

Parsing minified files is slow

Open smartt opened this issue 14 years ago • 2 comments

This, of course, needs a test case, and a definition of "slow". A quick look at crunching a yui-min.js field took:

  • 1.214 sec. using pypy 1.6
  • 5.032 sec. using python 2.6
  • 7.281 sec using python 3.2

I am surprised to see any one file taking over a second.

(For what it's worth, python2.6 is normally the fastest for me at running the test suite; and python3.2 is the slowest.)

smartt avatar Aug 25 '11 15:08 smartt

I believe that if you remove the strip and foo replacements that the prcessing of that same file will be quite faster. The only thing that occurs to me is to have the foo and strip handlers only turned on with an option like -x which is for extended macro replacement features ?

Oh and also if you don't remove the @define xxx entries from the original file the calls ot the regex.sub(xxx) are quite heavy. I'll come up with a few ideas later in the day on how we can speed this up or have an option like -x for extended macro replacements (ie date, time) and another for stripping the define's such as --deldefines

rlgomes avatar Aug 25 '11 17:08 rlgomes

My pull request #12 adds an exclude functionality for just this reason. I had some large minified files all under a js/vendor directory and they took many seconds to parse, but I didn't need them to be parsed because they didn't have anything jsmacro needed to process in them. Sure it's a workaround but one that works well for me in practice. I wouldn't spit on parsing speed increases of course!

Skylark13 avatar Feb 11 '13 21:02 Skylark13