mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Speed the Windows code by using native 64-bit int compiler support instead
of calling external functions.
This commit is contained in:
parent
de26cfc1e1
commit
7d99ff27e8
1 changed files with 14 additions and 11 deletions
|
|
@ -20,8 +20,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <largeint.h>
|
#include <largeint.h>
|
||||||
#include <direct.h> /* for getcwd() */
|
#include <direct.h> /* for getcwd() */
|
||||||
typedef LARGE_INTEGER hs_time;
|
typedef __int64 hs_time;
|
||||||
#define GETTIMEOFDAY(p) QueryPerformanceCounter(p)
|
#define GETTIMEOFDAY(P_HS_TIME) \
|
||||||
|
{ LARGE_INTEGER _temp; \
|
||||||
|
QueryPerformanceCounter(&_temp); \
|
||||||
|
*(P_HS_TIME) = _temp.QuadPart; }
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#ifndef HAVE_GETTIMEOFDAY
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
|
|
@ -664,12 +668,11 @@ get_tdelta(ProfilerObject *self)
|
||||||
int tdelta;
|
int tdelta;
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
hs_time tv;
|
hs_time tv;
|
||||||
LARGE_INTEGER diff;
|
hs_time diff;
|
||||||
|
|
||||||
QueryPerformanceCounter(&tv);
|
GETTIMEOFDAY(&tv);
|
||||||
diff = LargeIntegerSubtract(tv, self->prev_timeofday);
|
diff = tv - self->prev_timeofday;
|
||||||
|
tdelta = (int)diff;
|
||||||
tdelta = diff.LowPart;
|
|
||||||
#else
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
|
@ -764,7 +767,7 @@ calibrate(void)
|
||||||
hs_time tv1, tv2;
|
hs_time tv1, tv2;
|
||||||
|
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
LARGE_INTEGER diff;
|
hs_time diff;
|
||||||
QueryPerformanceFrequency(&frequency);
|
QueryPerformanceFrequency(&frequency);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -772,9 +775,9 @@ calibrate(void)
|
||||||
while (1) {
|
while (1) {
|
||||||
GETTIMEOFDAY(&tv2);
|
GETTIMEOFDAY(&tv2);
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
diff = LargeIntegerSubtract(tv2, tv1);
|
diff = tv2 - tv1;
|
||||||
if (!LargeIntegerEqualToZero(diff)) {
|
if (diff != 0) {
|
||||||
timeofday_diff = diff.LowPart;
|
timeofday_diff = (unsigned long)diff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue