Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3917c221
Kaydet (Commit)
3917c221
authored
Nis 02, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Win32 precision clock() -- Mark Hammond.
üst
9bf84455
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
1 deletion
+44
-1
timemodule.c
Modules/timemodule.c
+44
-1
No files found.
Modules/timemodule.c
Dosyayı görüntüle @
3917c221
...
@@ -79,6 +79,12 @@ extern int ftime();
...
@@ -79,6 +79,12 @@ extern int ftime();
#endif
/* MS_WINDOWS */
#endif
/* MS_WINDOWS */
#endif
/* !__WATCOMC__ */
#endif
/* !__WATCOMC__ */
#ifdef MS_WIN32
/* Win32 has better clock replacement */
#include <largeint.h>
#undef HAVE_CLOCK
/* We have our own version down below */
#endif
/* MS_WIN32 */
/* Forward declarations */
/* Forward declarations */
static
int
floatsleep
Py_PROTO
((
double
));
static
int
floatsleep
Py_PROTO
((
double
));
static
double
floattime
Py_PROTO
(());
static
double
floattime
Py_PROTO
(());
...
@@ -120,6 +126,43 @@ time_clock(self, args)
...
@@ -120,6 +126,43 @@ time_clock(self, args)
}
}
#endif
/* HAVE_CLOCK */
#endif
/* HAVE_CLOCK */
#ifdef MS_WIN32
/* Due to Mark Hammond */
static
PyObject
*
time_clock
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
static
LARGE_INTEGER
ctrStart
;
static
LARGE_INTEGER
divisor
=
{
0
,
0
};
LARGE_INTEGER
now
,
diff
,
rem
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
(
LargeIntegerEqualToZero
(
divisor
))
{
QueryPerformanceCounter
(
&
ctrStart
);
if
(
!
QueryPerformanceFrequency
(
&
divisor
)
||
LargeIntegerEqualToZero
(
divisor
))
{
/* Unlikely to happen -
this works on all intel machines at least!
Revert to clock() */
return
PyFloat_FromDouble
(
clock
());
}
}
QueryPerformanceCounter
(
&
now
);
diff
=
LargeIntegerSubtract
(
now
,
ctrStart
);
diff
=
LargeIntegerDivide
(
diff
,
divisor
,
&
rem
);
/* XXX - we assume both divide results fit in 32 bits. This is
true on Intels. First person who can afford a machine that
doesnt deserves to fix it :-)
*/
return
PyFloat_FromDouble
((
double
)
diff
.
LowPart
+
((
double
)
rem
.
LowPart
/
(
double
)
divisor
.
LowPart
));
}
#define HAVE_CLOCK
/* So it gets included in the methods */
#endif
/* MS_WIN32 */
static
PyObject
*
static
PyObject
*
time_sleep
(
self
,
args
)
time_sleep
(
self
,
args
)
PyObject
*
self
;
PyObject
*
self
;
...
@@ -131,7 +174,7 @@ time_sleep(self, args)
...
@@ -131,7 +174,7 @@ time_sleep(self, args)
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
if
(
floatsleep
(
secs
)
!=
0
)
{
if
(
floatsleep
(
secs
)
!=
0
)
{
Py_BLOCK_THREADS
Py_BLOCK_THREADS
return
NULL
;
return
NULL
;
}
}
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment