which is faster?
-
Hi In my app i have to read thousands of lines of data written in a text file. I have saved the lines previously. The size of text file is 50 MB. My problem is that it takes a lot of time to read that. If i save the lines in a database, would the 'reading' be faster?
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
-
Hi In my app i have to read thousands of lines of data written in a text file. I have saved the lines previously. The size of text file is 50 MB. My problem is that it takes a lot of time to read that. If i save the lines in a database, would the 'reading' be faster?
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
Hi, I very much doubt reading 50MB of data is taking very long, it should be possible to do that in say 1 second. If your app is slower at it, it probably is due to what it is you do with the data, such as adding it to some of the GUI controls. Tell us more, and show some relevant code. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Hi, I very much doubt reading 50MB of data is taking very long, it should be possible to do that in say 1 second. If your app is slower at it, it probably is due to what it is you do with the data, such as adding it to some of the GUI controls. Tell us more, and show some relevant code. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
Hi Luc, Thanks for reply. Yes I do more than reading. I read the file.
Dim s$ = my...readalllines(myfile.txt)
There are sentences separated by # which I transfer in an array so that one sentence get into one element of array using simple code of 6 lines. This operation I do in the variable s. that's all I do. The size of the testing file is 10 MB and it takes about 4 min and 24 s The size of real file is nearly 50 MB. So what do you suggest now?
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
-
Hi Luc, Thanks for reply. Yes I do more than reading. I read the file.
Dim s$ = my...readalllines(myfile.txt)
There are sentences separated by # which I transfer in an array so that one sentence get into one element of array using simple code of 6 lines. This operation I do in the variable s. that's all I do. The size of the testing file is 10 MB and it takes about 4 min and 24 s The size of real file is nearly 50 MB. So what do you suggest now?
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
Prankur Rusia wrote:
So what do you suggest now?
Huh? The same as I suggested some 10 hours ago. You haven't given any new facts. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
Prankur Rusia wrote:
So what do you suggest now?
Huh? The same as I suggested some 10 hours ago. You haven't given any new facts. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
Hi I got the answer to my question. The file gets read quickly but the sorting in to the array takes time. There one thing I would like to ask you. The basic purpose of this is to search within the text file for a word. As there can be multiple occurrences of that word I first put the sentences, sentence by sentence, into an array. Then I search the array element by element to find the word by looping through the array. Now if I use the database, I would have access to the data already sorted sentence-wise. Then I just need to loop the database to search. Now I wanted to ask you, if I use the above defined process, will it be faster? Is the algorithm I am following is an efficient one? I know you are a busy man. But please spare a minute and tell me. Thanks.
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
-
Hi I got the answer to my question. The file gets read quickly but the sorting in to the array takes time. There one thing I would like to ask you. The basic purpose of this is to search within the text file for a word. As there can be multiple occurrences of that word I first put the sentences, sentence by sentence, into an array. Then I search the array element by element to find the word by looping through the array. Now if I use the database, I would have access to the data already sorted sentence-wise. Then I just need to loop the database to search. Now I wanted to ask you, if I use the above defined process, will it be faster? Is the algorithm I am following is an efficient one? I know you are a busy man. But please spare a minute and tell me. Thanks.
TheMrProgrammer http://www.icbse.com/2009/funny-exam-answers-school-students http://download.cnet.com/TheCalcMan/3000-2094\_4-10958266.html
I can do that in a fast way with or without a database. And everyone can come up with a slow implementation with or without a database. Getting it slow with a database is harder to achieve, since there is less code to mess with. FYI: de database has to read the data from disk too, and search your string too, so why would it really be faster? :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.