develooper Front page | perl.beginners | Postings from May 2008

Re: Initialize object permanently

Thread Previous
From:
Chas. Owens
Date:
May 16, 2008 07:54
Subject:
Re: Initialize object permanently
On May 16, 2008, at 04:55, anthony brooke wrote:

> Hello, I am using Wordnet::QueryData which allow access to a very  
> huge dictionary data. The initialization of object
> my $wn = WordNet::QueryData->new;
>
> took
> 2 wallclock secs ( 2.36 usr +  0.07 sys =  2.43 CPU)
>
> Then the subsequent request for the data is exetremely fast
>
> For the lines below took
> 0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
>
> print "Synset: ", join(", ", $wn->querySense("cat#n#7", "syns")),  
> "\n";
> print "Hyponyms: ", join(", ", $wn->querySense("cat#n#1", "hypo")),  
> "\n";
> print "Parts of Speech: ", join(", ", $wn->querySense("run")), "\n";
> print "Senses: ", join(", ", $wn->querySense("run#v")), "\n";
> print "Forms: ", join(", ", $wn->validForms("lay down#v")), "\n";
> print "Noun count: ", scalar($wn->listAllWords("noun")), "\n";
> print "Antonyms: ", join(", ", $wn->queryWord("dark#n#1", "ants")),  
> "\n";
>
> I
> am developing a web application, is there a way to make the
> initialization of object permanently in memory ? I tried to use the
> Storable module. But that only give me a little increase in
> performance. Anybody's idea is very much appreciated, Thank you.

Your best bet is to take a daemon like approach.  Startup a script  
that does nothing but respond to requests by other scripts.  Take a  
look at the IPC::* modules to see how to do inter-process communication.

Thread Previous


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About