Camm Maguire <c...@maguirefamily.org> writes:

| Greetings!
| 
| Gabriel Dos Reis <g...@cs.tamu.edu> writes:
| 
| > Camm Maguire <c...@maguirefamily.org> writes:
| >
| > | Greetings!
| > | 
| > | Gabriel Dos Reis <g...@cs.tamu.edu> writes:
| > | 
| > | > Camm Maguire <c...@maguirefamily.org> writes:
| > | >
| > | > | Greetings, and thanks!  Should be fixed now.  Please let me know if
| > | > | problems persist.
| > | >
| > | > Everything builds fine this time around.  Hurray!
| > | >
| > | 
| > | Great!
| > | 
| > | 1) Any microsecond clock function on windows like gettiemofday()?
| >
| > There are GetSystemTime and GetLocalTime to be called with a pointer to
| > a SYSTEMTIME structure.  See
| >
| >    http://msdn.microsoft.com/en-us/library/ms724390%28VS.85%29.aspx
| >    http://msdn.microsoft.com/en-us/library/ms724950%28v=VS.85%29.aspx
| >
| >
| 
| Thanks, but I need microseconds.  Anyone object to:
| 
| 
DEFUN_NEW("GETTIMEOFDAY",object,fSgettimeofday,SI,0,0,NONE,OO,OO,OO,OO,(void),"Return
 time with maximum resolution") {
| #ifdef __MINGW32__
|   /* static struct timeb t0; */
|   /* static unsigned u; */
|   /* struct timeb t;  */
|   /* ftime(&t); */
|   /* if (t.time!=t0.time || t.millitm!=t0.millitm) {t0=t;u=0;} */
|   /* u++; */
|   /* return 
make_longfloat(((longfloat)t.time+1.0e-3*t.millitm+1.0e-6*(u%1000)));  */
|   LARGE_INTEGER uu;
|   QueryPerformanceCounter(&uu);
|   return make_longfloat((longfloat)uu.QuadPart*1.0e-6);
| #endif  

Hmm, I think you want to divide by the the number of ticks per second
as returned by QueryPerformanceFrequency(), see

  http://msdn.microsoft.com/en-us/library/ms886789.aspx

furthermore, since these days the frequence is not fixed in time and
depends on the `performance profile' of the machine at any single time,
you can't cache the value of QueryPerformanceFrequency() and reuse it.

I believe you need something like:

    LARGE_INTEGER ticks;
    if (QueryPerformanceFrequency(&ticks)) {
       /* high resolution available.  /
       const double micros = 1.0e6/ticks.QuadPart;
       LARGE_INTEGER snapshot;
       QueryPerformanceCounter(&snapshot);
       return make_longfloat(snapshot.QuadPart * micros);
    else {
       /* high resolution not available.  Use something else. */
    }

-- Gaby


------------------------------------------------------------------------------
Achieve Improved Network Security with IP and DNS Reputation.
Defend against bad network traffic, including botnets, malware, 
phishing sites, and compromised hosts - saving your company time, 
money, and embarrassment.   Learn More! 
http://p.sf.net/sfu/hpdev2dev-nov
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to