I sure as heck hope someone out there has an answer for me on this
one...

Has anyone else seen inefficiencies with arrays?


I have a file with 1000 rows that looks
     "this","that","other","etc","etc"
     "again","this","is","another","row"

I load that into an Array called "values" splitting on ",". That all
works fine. The array builds happily and quickly. But when I populate an
object from that array (see below) it's slow as Christmas.

Here is an example of what I am doing:

if(false) {
     // 1000 @ 2 seconds : 50k Rows in 1 min 40 sec
     val1     = new String("123456");
     val2     = new String("12/12/2005");
     val3     = new String("12/13/2005");
     val4     = new String("asdfjklmsd  mjnklsdf");
     val5     = new String("asdfjklal  alamjnklsdf");
     val6     = new String("aasd9asdf;lj asdf");
     val7     = new String("aaa2a6236523");
     val8     = new String("IP");
} else if(true) {
     // 1000 @ 8 seconds : 50k Rows in 6 min 20 sec
     val1     = values[0];
     val2     = values[1];
     val3     = values[2];
     val4     = values[3];
     val5     = values[4];
     val6     = values[5];
     val7     = values[6];
     val8     = values[7];
}



Notice that the top if is putting in hard-coded values and the bottom
one is using the "values" array I created. It's 4 times slower.

This makes using files over 5,000 rows very painful. And certainly puts
an upward limit on how much data I can slurp in.

Mind you that this is not a result of reading the file (very very fast)
nor creating the "values" array for each row. I am creating the "values"
array in both scenarios above. So that's included in the time.

Someone please tell me I'm being an idiot here somehow. Maybe I should
be using an ArrayCollection, or referencing values via the index of an
array is terribly slow... something obvious?

Reply via email to