Date: Tue, 13 Aug 2002 14:55:14 -0500 (CDT) From: Gilles Detillieux To: Jim Cole Cc: "ht://Dig - Dev" Subject: Re: [htdig-dev] Feature: Execution time According to Jim Cole: > I agree with not adding this to the 3.1.x code, but it would be > great if you could make a 3.1.6 patch available :) That's easy enough... This patch shows the effective execution time of an htsearch query, in seconds. Tue Aug 13 11:44:01 CEST 2002 Gabriele Bartolini * htsearch/Display.[h,cc]: added execution time feature (EXECUTIONTIME template variable) * htsearch/htsearch.cc: calculates the execution time through 'gettimeofday' --- htsearch/Display.h.orig Thu Nov 1 16:23:32 2001 +++ htsearch/Display.h Tue Aug 13 10:26:24 2002 @@ -40,6 +40,7 @@ public: void setLogicalWords(char *); void setOriginalWords(char *); void setCGI(cgi *); + void setExecutionTime(int milliseconds); void display(int pageNumber); void displayMatch(ResultMatch *, int current); @@ -147,6 +148,11 @@ protected: TemplateList templates; Template *currentTemplate; + // + // Execution time + // + String execution_time; + // // Methods... // @@ -220,6 +226,20 @@ inline void Display::setCGI(cgi *aCgi) { input = aCgi; +} + +inline void +Display::setExecutionTime(int milliseconds) +{ + if (milliseconds > 0) + { + char value[8]; + snprintf(value, 8, "%.2f", (float) milliseconds / 1000); + + execution_time << value; + } + else + execution_time = '?'; // very unlikely to happen } #endif --- htsearch/Display.cc.orig Wed Jan 16 23:00:17 2002 +++ htsearch/Display.cc Tue Aug 13 09:49:08 2002 @@ -30,6 +30,7 @@ extern int debug; //***************************************************************************** // Display::Display(char *indexFile, char *docFile) +: execution_time(0) { docIndex = Database::getDatabaseInstance(); docIndex->OpenRead(indexFile); @@ -434,6 +435,7 @@ Display::setVariables(int pageNumber, Li vars.Add("ENDYEAR", new String(config["endyear"])); vars.Add("ENDMONTH", new String(config["endmonth"])); vars.Add("ENDDAY", new String(config["endday"])); + vars.Add("EXECUTIONTIME", new String(execution_time)); String *str; char *format = input->get("format"); --- htsearch/htsearch.cc.orig Fri Jan 18 Jan 21:59:47 2002 +++ htsearch/htsearch.cc Tue Aug 13 Aug 09:49:08 2002 @@ -21,6 +21,7 @@ static char RCSid[] = "$Id: htsearch.cc, #include "WordList.h" #include "StringList.h" #include "IntObject.h" +#include #include #include #include @@ -70,6 +71,8 @@ main(int ac, char **av) StringMatch searchWordsPattern; StringList requiredWords; int i; + struct timeval start_time, end_time; + gettimeofday(&start_time, 0); // Set the start time // // Parse command line arguments @@ -338,6 +341,7 @@ main(int ac, char **av) filenamemsg.get())); return 0; } + display.setOriginalWords(originalWords); display.setResults(results); display.setSearchWords(&searchWords); @@ -346,6 +350,15 @@ main(int ac, char **av) display.setAllWordsPattern(&searchWordsPattern); display.setCGI(&input); display.setLogicalWords(logicalWords); + + // Set the execution time in milliseconds + gettimeofday(&end_time, 0); // Set the end time + + // Pass it to the display object + display.setExecutionTime( (int) ( + ((end_time.tv_sec - start_time.tv_sec) * 1000) // seconds in milliseconds + + ((float)(end_time.tv_usec - start_time.tv_usec) / 1000))); // microseconds in milliseconds + if (parser->hadError()) display.displaySyntaxError(parser->getErrorMessage()); else @@ -353,6 +366,7 @@ main(int ac, char **av) delete results; delete parser; + return 0; } -- Gilles R. Detillieux E-mail: Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/ Dept. Physiology, U. of Manitoba Winnipeg, MB R3E 3J7 (Canada) ------------------------------------------------------- This sf.net email is sponsored by: Dice - The leading online job board for high-tech professionals. Search and apply for tech jobs today! http://seeker.dice.com/seeker.epl?rel_code=31 _______________________________________________ htdig-dev mailing list htdig-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/htdig-dev