delorie.com/archives/browse.cgi | search |
From: | Alex Vinokur <alexvn AT bigfoot DOT com> |
Newsgroups: | comp.os.msdos.djgpp,comp.lang.c++ |
Subject: | Re: Optimization and operator&& |
Date: | Wed, 05 Jun 2002 14:41:56 +0200 |
Lines: | 83 |
Message-ID: | <3CFE0713.55B88072@bigfoot.com> |
References: | <3CFCB642 DOT 252CFFF7 AT bigfoot DOT com> <adigc2$n1d$03$1 AT news DOT t-online DOT com> <3CFCDBF9 DOT CCDA33 AT bigfoot DOT com> <adin9l$s7q$00$1 AT news DOT t-online DOT com> <adkstq$1q4d$1 AT ID-79865 DOT news DOT dfncis DOT de> |
NNTP-Posting-Host: | gateway.scopus.net (62.90.123.5) |
Mime-Version: | 1.0 |
X-Trace: | fu-berlin.de 1023277200 68276 62.90.123.5 (16 [79865]) |
X-Mailer: | Mozilla 4.7 [en] (Win98; I) |
X-Accept-Language: | en |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Alex Vinokur wrote: > "Heinz Ozwirk" <wansor42 AT gmx DOT de> wrote in message > news:adin9l$s7q$00$1 AT news DOT t-online DOT com... > > "Alex Vinokur" <alexvn AT bigfoot DOT com> wrote in message > [snip] > > But that doesn't answer your question, and I cannot do so. Common sense > > suggests that optimized code should be faster than plain code and if a > > compiler slows down a program when optimizing might be a hint that the > > compiler does something wrong. Or the uclock() function is not the proper > > tool for timing code. > > > > Similar results have been received when using the getrusage() function > http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?getrusage+3 > and 'struct timeval ru_stime' in 'struct rusage'. Something like : ------------------------ #include <sys/resource.h> #include <iostream> unsigned long get_diff_time ( const rusage& start_time_i, const rusage& end_time_i ) { double ret_double_value = ( end_time_i.ru_utime.tv_sec - start_time_i.ru_utime.tv_sec ) + ( end_time_i.ru_utime.tv_usec - start_time_i.ru_utime.tv_usec )/ 1.0e6; unsigned long ret_ulong_value; ret_ulong_value = static_cast<unsigned long>(ret_double_value * 1000000); return ret_ulong_value; } int main () { getrusage(RUSAGE_SELF, &start_time); // Stuff getrusage(RUSAGE_SELF, &end_time); cout << get_diff_time (start_time, end_time) << endl; return 0; } ------------------------ > > > > Regards > > Heinz > > > > Regards, =========================== Alex Vinokur mailto:alexvn AT bigfoot DOT com mailto:alexvn AT go DOT to http://up.to/alexvn http://go.to/alexv_math ===========================
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |