Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Search Timer (Like Google)

Quote Reply
Search Timer (Like Google)
A lot of you have probably read the thread in the forum discussing this mod but I though Id give proper instructions here:

If you want to time your searches like google does so that on your results page you can have something like:

Search took 0.56 seconds

....then firstly open search.cgi and find sub search {

Underneath print $IN->header;

...put _time_start();

...then delete the next 2-3 lines of code up to if (defined $results->{error}) {

...and replace with...

my $results = GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'search_results', \&query, {});
$results->{query_time} = _time_display();


...at the bottom of search.cgi add...

sub _time_start {
# ------------------------------------------------------------------
# Start a timer.
#
BEGIN { local $@; eval { require Time::HiRes; import Time::HiRes qw/time/; }; }
$TIME_START = time;
}

sub _time_display {
# ------------------------------------------------------------------
# Return time results.
#
my $end = time;
my $elapsed = sprintf ("%.2f", $end - $TIME_START);
return $elapsed;
}


You can now add the tag <%query_time%> into your search_results.html template and the search time will be printed.

To get the search time in milliseconds you will need to install the Time::HiRes perl module.

This can be done by issuing the following command...

perl -MCPAN -e 'install Time::HiRes' at the telnet or SSH prompt.

If you dont have root access, you host will have to do this as you will not have permission to write to the perl5 library directory.

THANKS Alex...for help with this mod!


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: [PaulW] Search Timer (Like Google) In reply to
I have made the changes you have stated, but when I put <%query_time%> in my results template, I get an unknown tag error.

Sean
Quote Reply
Re: [SeanP] Search Timer (Like Google) In reply to
This is quite an old thread and was for a much older version of Links SQL. I'll see what I can do about making a new version.
Quote Reply
Re: [PaulW] Search Timer (Like Google) In reply to
Paul, I use that as a plugin you created some time ago and still works great with my 2.5 installation. Do you not have that copy? If not, I can email you the plugin (hehe - sending you YOUR own creation!)

P.S. Please nobody ask me to email the code as this would be inappropriate - I'm not the author of the plugin.

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] Search Timer (Like Google) In reply to
Hi yeah if you could send me a copy that would be great. Thanks :)
Quote Reply
Re: [PaulW] Search Timer (Like Google) In reply to
This looks like a great plugin. I am upgrading hardware in my server, and this would be very useful in determining the speed of my searches. I hope you will add this to the resource area when you get it. Smile

Sean
Quote Reply
Re: [PaulW] Search Timer (Like Google) In reply to
Paul,

Did you ever get a copy of your plugin? If so, do you mind to share?

Sean
Quote Reply
Re: [SeanP] Search Timer (Like Google) In reply to
Hi,

I'll try and get this done today.