Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Increase file reading efficiency
March 19, 2008, 5:26 pm
rate this thread
is slow (appx. 10-15 seconds), but queries are very fast thereafter---
thousands of queries can be completed every second. " as stated by the
author, because it needs to read very big WordNet lexicon in many TEXT
files. I am new to perl, I like to know if there is a way I could
reduce the initialization time ? Thank you
Re: Increase file reading efficiency
On my system, it only takes about 2 seconds. So the easiest way would
be to get modern hardware :) Or you could try to rearrange things so you
need to start up the script less and use it more for each time it is
started (for example, use mod_perl instead of CGI).
Another option would be to store the database in a form that can be
reloaded much easier, which is what the Storable module does.
This creates a serialized object in a file named "file":
my $x= WordNet::QueryData->new();
store $x, "file";
The delete $x->; is there because Storable can't store open
This script would need to be run once each time WordNet
database is updated.
Then, when you go to use the database, you would no longer load
the object with WordNet::QueryData->new(), instead would load it from
the saved data:
# now use $x just as if it was created via new
The purpose of $x->openData is to repopulate the previously deleted
$x->. I haven't tested this rigorously.
This cuts the start-up time to 0.5 seconds, so only a 4 fold improvement.
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate