We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everybody
I wanted to make a small test in order to check Processing perfomances compared to something else i am also learning (xojo , "real basic").
So basically my test consist of loading very simple txt file containing about 4000 lines of random characters (likes: "498e4g6q4c4r74u4olp4trfe4zd5dg44" ) each lines are of the same length. and then I want to display these line in a textarea (I am using G4P library for this)
I encounter two problems :
it takes ages to execute. I have tried to reduce the number of lines to load but even with 1000 it takes something like 5 minutes before displaying anything.
So I am wondering if there is something wrong in my (I guess that's most likely the case :) ) or is processing just not the right language for doing these kind of things ?
here is my code :
//import g4p_controls.*;
String txtfile[] = loadStrings("c:\\list.txt");
String[] lines;
void setup() {
size(800, 650);
//createGUI();
}
void draw() {
for (int i=0; i < txtfile.length; i++) {
lines = split(txtfile[i], ENTER);
// textarea1.appendText( i + " > " + lines);
println( lines + " ");
}
}
Oh an other thing : instead of the lines I should see from my txt file it displays things like "[Ljava.lang.String;@78b25336 " I don't know why .
Answers
Some things:
The G4P textarea is not designed to append 4000 lines of text show quickly and will seriously affect the overall performance.
Be wary of speed comparison tests it is difficult to get consistent results, especially if you are using disk input/output and console output because there are many things outside the control of the language that can affect performance.
[Ljava.lang.String;@78b25336
When you use println to display the value of an object it uses the toString() method to decide what to display. If the object's class has no toString method then it uses the one in the Object class. Java treats arrays as objects so the above line indicates that it is a single dimension String array stored at the address 78bb25336 (hexadecimal)
Thanks a lot for your answer , understand better now
Actually, arrays are indeed objects. But it's the only 1 w/o a formal class and uses
[]
for access! :-B