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.
(Dont blame me if I'm wrong!)
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.
(Dont blame me if I'm wrong!)