Say I have the code below:
Note that DBI *dbh isn't used. That should be irrelevant, since its constructor doesn't care.Code:#include <dbi.h> using std::cout; int main() { clock_t t_start = clock(); clock_t t_fin; DBI *dbh = new DBI; // position 1 cout<< "Content-type: text/html\n\n"; for( long i=0; i<1000000000; i++ ) ; cout<< "Counted to a billion!<br />"; //DBI *dbh = new DBI; // position 2 char *env_qs = getenv("QUERY_STRING"); if( *env_qs == NULL ) cout<< "exe failed it's purpose<br />"; else cout<< "You said <span style=\"font-family:sans-serif;\">\"" << env_qs << "\"</span> to me<br />"; t_fin = clock(); cout<< "code took about " << (double)(t_fin - t_start) / CLOCKS_PER_SEC << " secs"; delete dbh; return 0; }
The app usually takes ~2.5-2.8 secs to complete when the commented line is in position 2, but ~3.75-4 secs in position 1. I am utterly baffled that there is a difference, let alone the (relatively) huge discrepancy that comes up here. I've made sure the difference is consistent, and not just me but I haven't a clue as to explaining it. Any suggestions?



LinkBack URL
About LinkBacks


