Mail Archives: djgpp/2002/04/29/02:19:11
"Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> wrote in message news:3CCC0690 DOT CFF305C6 AT is DOT elta DOT co DOT il...
| Alex Vinokur wrote:
| >
| > Unfortunaly the clock() has insufficient time accuracy.
| > Details :
| > 1. Log file : on Windows2000 when using clock()
| > http://groups.google.com/groups?selm=aa8ubf%248pubf%241%40ID-79865.news.dfncis.de
| > (or news:aa8ubf$8pubf$1 AT ID-79865 DOT news DOT dfncis DOT de in news:misc.test )
| > 2. Log file : on Windows98 when using uclock()
| > http://alexvn.freeservers.com/s1/pf_dir/log5.txt
|
| Sorry, I cannot figure out what does the URL under 1. say, and I cannot
| access number 2.
I don't know why there is a problem with access to http://alexvn.freeservers.com/s1/pf_dir/log5.txt
|
| Can you summarize what you see on these two systems? What accuracy do you
| observe?
Summary :
|| ###### C++ Pseudocode : BEGIN ######
// Something like
#define TOTAL_ITERATIONS <Some number>
#define PER_CALLS <Some number>
// PER_CALLS < TOTAL_ITERATIONS
// -----------------------
class ClassPerfoMeterUclock
{
private :
uclock_t start_time_;
uclock_t end_time_;
public :
ClassPerfoMeterUclock ()
{
start_time_ = uclock();
}
~ClassPerfoMeterUclock ()
{
end_time_ = uclock();
// Calculation run time (per PER_CALLS);
}
}
// -----------------------
class ClassPerfoMeterClock
{
private :
clock_t start_time_;
clock_t end_time_;
public :
ClassPerfoMeterClock ()
{
start_time_ = clock();
}
~ClassPerfoMeterClock ()
{
end_time_ = clock();
// Calculation run time (per PER_CALLS);
}
}
// -----------------------------
void demo_11 (void)
{
char str[] = "ABCD";
#ifded WIN98
ClassPerfoMeterUclock ins_meter();
#endif
#ifded WIN2000
ClassPerfoMeterClock ins_meter();
#endif
for (int i = 0; i < TOTAL_ITERATIONS; i++ )
{
strlen(str);
}
}
|| ###### C++ Pseudocode : END ########
|| ###### Windows98 & uclock : BEGIN ######
========================
Windows98
gcc version 2.95.3
GNU C++ version 2.95.3 20010315/djgpp (release) (djgpp)
compiled by GNU C version 2.95.3 20010315/djgpp (release).
========================
-------------------------
--- Testing demo_11() ---
-------------------------
-- TOTAL_ITERATIONS == 90000
-- PER_CALLS == 10000
---------------------------------------------
--- Results sorted according to a test number
---------------------------------------------
Test[ 1] : 582 [ 90000 iterations]
Test[ 2] : 583 [ 90000 iterations]
Test[ 3] : 582 [ 90000 iterations]
Test[ 4] : 684 [ 90000 iterations]
Test[ 5] : 582 [ 90000 iterations]
Test[ 6] : 583 [ 90000 iterations]
Test[ 7] : 583 [ 90000 iterations]
Test[ 8] : 582 [ 90000 iterations]
Test[ 9] : 583 [ 90000 iterations]
Test[ 10] : 582 [ 90000 iterations]
Test[ 11] : 583 [ 90000 iterations]
Test[ 12] : 590 [ 90000 iterations]
Test[ 13] : 582 [ 90000 iterations]
Test[ 14] : 583 [ 90000 iterations]
Test[ 15] : 582 [ 90000 iterations]
|| ###### Windows98 & uclock : END ########
|| ###### Windows2000 & clock : BEGIN ######
========================
Windows-2000
Intel(R) Pentium
R(4) CPU 1.70GHz
gcc version 3.0.4
GNU CPP version 3.0.4 (cpplib) (80386, BSD syntax)
GNU C++ version 3.0.4 (djgpp) compiled by GNU C version 3.0.4.
Configured with: ../configure i586-pc-msdosdjgpp --prefix=/dev/env/DJDIR --disable-nls
Thread model: single
-- CLOCKS_PER_SEC == 91 --> from time.h
========================
-------------------------
--- Testing demo_11() ---
-------------------------
-- TOTAL_ITERATIONS == 750000
-- PER_CALLS == 250000
---------------------------------------------
--- Results sorted according to a test number
---------------------------------------------
Test[ 1] : 0 [ 750000 iterations] ---> Too small
Test[ 2] : 0 [ 750000 iterations] ---> Too small
Test[ 3] : 0 [ 750000 iterations] ---> Too small
Test[ 4] : 0 [ 750000 iterations] ---> Too small
Test[ 5] : 0 [ 750000 iterations] ---> Too small
Test[ 6] : 0 [ 750000 iterations] ---> Too small
Test[ 7] : 0 [ 750000 iterations] ---> Too small
Test[ 8] : 1 [ 750000 iterations]
Test[ 9] : 1 [ 750000 iterations]
Test[ 10] : 0 [ 750000 iterations] ---> Too small
Test[ 11] : 0 [ 750000 iterations] ---> Too small
Test[ 12] : 0 [ 750000 iterations] ---> Too small
Test[ 13] : 0 [ 750000 iterations] ---> Too small
Test[ 14] : 0 [ 750000 iterations] ---> Too small
Test[ 15] : 0 [ 750000 iterations] ---> Too small
|| ###### Windows2000 & clock : END ########
APPENDIX. File time.h on Windows2000
|| ###### Windows2000 -> File time.h : BEGIN ######
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef __dj_include_time_h_
#define __dj_include_time_h_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
/* 65536(tics/hour) / 3600(sec/hour) * 5(scale) = 91.02
The 5 is to make it a whole number (18.2*5=91) so that
floating point ops aren't required to use it. */
#define CLOCKS_PER_SEC 91
#include <sys/djtypes.h>
/* Some programs think they know better... */
#undef NULL
#define NULL 0
__DJ_clock_t
#undef __DJ_clock_t
#define __DJ_clock_t
__DJ_size_t
#undef __DJ_size_t
#define __DJ_size_t
__DJ_time_t
#undef __DJ_time_t
#define __DJ_time_t
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
char *__tm_zone;
int __tm_gmtoff;
};
char * asctime(const struct tm *_tptr);
clock_t clock(void);
char * ctime(const time_t *_cal);
double difftime(time_t _t1, time_t _t0);
struct tm * gmtime(const time_t *_tod);
struct tm * localtime(const time_t *_tod);
time_t mktime(struct tm *_tptr);
size_t strftime(char *_s, size_t _n, const char *_format, const struct tm *_tptr);
time_t time(time_t *_tod);
#ifndef __STRICT_ANSI__
#define CLK_TCK CLOCKS_PER_SEC
extern char *tzname[2];
void tzset(void);
#ifndef _POSIX_SOURCE
#define tm_zone __tm_zone
#define tm_gmtoff __tm_gmtoff
struct timeval {
time_t tv_sec;
long tv_usec;
};
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#include <sys/types.h>
typedef long long uclock_t;
#define UCLOCKS_PER_SEC 1193180
int gettimeofday(struct timeval *_tp, struct timezone *_tzp);
unsigned long rawclock(void);
int select(int _nfds, fd_set *_readfds, fd_set *_writefds, fd_set *_exceptfds, struct timeval *_timeout);
int settimeofday(struct timeval *_tp, ...);
void tzsetwall(void);
uclock_t uclock(void);
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
#ifdef __cplusplus
}
#endif
#endif /* !__dj_include_time_h_ */
|| ###### Windows2000 -> File time.h : END ########
Thanks in advance,
--
====================
Alex Vinokur
http://up.to/alexvn
http://go.to/alexv_math
mailto:alexvn AT bigfoot DOT com
mailto:alexvn AT go DOT to
====================
- Raw text -