H
Home Newbie
I have some stupid questions....
- Why would program 1 run faster than program 2? If I change the
sample_size to be a larger one, program 2 made my browser frozen!!
- What is the optimum value (1024 in this case) to use?
Program 1:
-----------
int sample_size = 5120; // 5K
for (i=0; i < (sample_size/1024); i++) {
my_buffer = "";
for (j=1; j<=1024; j++) {
my_buffer += "a";
}
my_data += my_buffer;
}
Program 2:
- Why would program 1 run faster than program 2? If I change the
sample_size to be a larger one, program 2 made my browser frozen!!
- What is the optimum value (1024 in this case) to use?
Program 1:
-----------
int sample_size = 5120; // 5K
for (i=0; i < (sample_size/1024); i++) {
my_buffer = "";
for (j=1; j<=1024; j++) {
my_buffer += "a";
}
my_data += my_buffer;
}
Program 2: