b19: clock() doesn't work !!!!!!!!!!! and times() too !!!!
Cezary Wagner
wagnerc@ee.pw.edu.pl
Mon Apr 20 18:19:00 GMT 1998
(this letter is budle of there that not comes to target (to many hops
!), sorry for not organized style of mail letter ...)
clock() ?
It always return the same value - it was dirty constnt value ...
It doesn't measure time ...
I test by code like (it should be the best show of problem):
for(;;)
cout << clock(); /* or printf */
34838
34838
34838 ... (and so on, forever ...)
and result still is the same (for b19 and b19.1 cygwin.dll) how to
measure
time with it when it constant ???
It was detected it on WIn98 beta 3, and I found that error could be
located it two calls:
GetCurrentProcess
GetProcessTimes
investigate times.cc for better knowledge, for ilustration of that I
attach program + source code (may be my binaries copy is broken ???)
I couldn't remove error because I can't recompile my cygnus b19 source
code (I go throught mounting root problem (hard to find), by I can't
make libg++ now (It stops at libgxx.list target ???)))
Thank you for help
Cezary (I am wait for your answer whatever It will be)
#include <iostream.h>
#include <ctime>
#include <list>
#include "stopper.hh"
const unsigned max_val = 200000;
int main()
{
list<unsigned> pl;
list<unsigned>::iterator i,j,k;
unsigned u, n, isprime;
Stopper st;
st.Start();
for(u = 2, n = 0, j = k = pl.begin();u != max_val;u++)
{
for(;j != pl.end()--;j++)
/* find last possible divisor for probable prime number */
/* current divisor must produce result great then its value
to be founded in prime list */
/* it based on that holes in prime list is even numbers or
numbers dividable by smaller primes than current
(see how prime list is builded up (from low to high and the
new prime is always greater value than divisors checken on it
for prime test commision)) */
if(u / *j < *j)
break;
for(i = pl.begin();i != j;i++)
{
/* check if it not prime */
if(u % *i == 0)
break; /* not prime break */
}
/* check if prime detected */
if(i == j)
{
n++;
isprime = 1;
pl.insert(pl.end(),u);
/* fix iterator for first prime from end() position
which will be undefinied by inserting first element
to the list */
if(pl.size() == 1)
j = k = pl.begin();
/* cout << u << "(" << pl.size() << ")("
<< *j << ")(" << u / *j << ")\n"; */
}
/* flushing entries every 1000 */
if(n % 1000 == 0 && n && isprime)
{
list<unsigned>::iterator last = pl.end();
st.Stop();
isprime = 0;
cout << *--last << "\n"
<< clock() << "\n";
st.Start();
}
}
st.Stop();
cout << "time = " << st.Time()
<< " speed = " << (u - 1) / st.Time() << "\n";
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.exe
Type: application/x-dosexec
Size: 13621 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/19980420/c8b88b1b/attachment.bin>
More information about the Cygwin
mailing list