I transposed code from a binary tree program that I wrote a few years ago into another language.
After a lot of twists and turns I arrive at the same number of nodes and words but on the other hand if the loading of the words from a text file takes less than a second in the old language, in RB it takes nearly 55 seconds.
it seems impossible to me but would you see an obvious reason for this type of data.
If someone has already made a binary tree with a fairly large number of words (~ 400,000 from 2 to 15 letters) I would be grateful to him because after so many hours of work if the loading of the tree is so slow, this no longer even worth it.
I can show the code which is not very long or even attach the program but I do not know if it is possible on the forum.
Thanking you in advance.
How is the data laid out in the file? If it is one word per row and you’re reading them one line at a time, that’s going to be slow. You can speed it up by reading the entire file into a string and then splitting on EndOfLine.
Thanks Tim, indeed I was reading line by line a text file with one word per line. But unfortunately we do not win anything by using the streams. I encounter some strange things but the more I restart the program the more the loading time of the binary tree increases. The minimum time for 400,000 words is 31 and then increases, … 40, … 50 seconds
Maybe it’s due to a pointers issue? I never did it but could we call a compiled external function?
Before looking for a solution to my problem, could I use a shell or create a dll with a compiled function to load the binary tree (is it complicated to do?) or maybe more simply in a thread like I don’t need the tree immediately after launching the program.
Thank you in advance.
Can you provide the code + a sample file for us to look at?
I will try to prepare a simplified program that only deals with this part.