Creating and parsing huge strings with javascript?

Posted by user246114 on Stack Overflow See other posts from Stack Overflow or by user246114
Published on 2010-04-26T05:14:29Z Indexed on 2010/04/26 5:23 UTC
Read the original article Hit count: 146

Filed under:

Hi,

I have a simple piece of data that I'm storing on a server, as a plain string. It is kind of ridiculous, but it looks like this:

name|date|grade|description|name|date|grade|description|repeat for a long time

this string can be up to 1.4mb in size. The idea is that it's a bunch of student records, just strung together with a simple pipe delimeter. It's a very poor serialization method.

Once this massive string is pushed to the client, it is split along the pipes into student records again, using javascript.

I've been timing how long it takes to create, and split, these strings on the client side. The times are actually quite good, the slowest run I've seen on a few different machines is 0.2 seconds for 10,000 'student records', which has a final string size of ~1.4mb.

I realize this is quite bizarre, just wondering if there are any inherent problems with creating and splitting such large strings using javascript? I don't know how different browsers implement their javascript engines. I've tried this on the 'major' browsers, but don't know how this would perform on earlier versions of each.

Yeah looking for any comments on this, this is more for fun than anything else!

Thanks

© Stack Overflow or respective owner

Related posts about JavaScript