pacerier — 2010-11-03T08:25:06-04:00 — #1
ok basically im building a script that reads input and have to "make meaning" or the input. now basically im not worried about how to do the implementation, but im worried about how slow or how fast the script may run if i choose the wrong method. which would be preferred?:
- read chars 1 by 1
- Split that string into multiple sections, which are furthur split into more sections.
- a combination of the 2?
aussiejohn — 2010-11-04T19:02:54-04:00 — #2
I would think that simply reading the value of a field as a whole string would be the fastest method.
Do you perhaps have an example / use case to better illustrate your problem?
pacerier — 2010-11-05T06:37:54-04:00 — #3
erm not really. im using the charAt right now, but im worried if there is any performance issues with charAt when the string gets v long. say 15000 chars
aussiejohn — 2010-11-07T07:08:41-05:00 — #4
If your input expectations are that long, is it really necessary to re-interpret the string character-by-character?
What you're actually going to do with the string once you've read it will affect performance more than the actual string reading.
Performance is also heavily dependent on the browser you're testing in. For example, a simple array.push() on 1,000,000 characters read in using charAt() in a for look will take approximately 30ms in Chrome, but can take up to 1400ms in IE8 (and about 450ms in Fx 3.6).
Could you perhaps give a use case of how you would need to interpret the string, what sort of things need to be done to it to "make meaning" out of it?