0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 11:15:56 +01:00
cpython/Modules/timingmodule.c

76 lines
1.1 KiB
C
Raw Normal View History

/*
* Author: George V. Neville-Neil
*/
1997-01-13 23:57:42 +01:00
#include "Python.h"
/* Our stuff... */
#include "timing.h"
1997-01-13 23:57:42 +01:00
static PyObject *
2000-07-10 14:04:18 +02:00
start_timing(PyObject *self, PyObject *args)
{
1997-01-13 23:57:42 +01:00
if (!PyArg_Parse(args, ""))
return NULL;
1997-01-13 23:57:42 +01:00
Py_INCREF(Py_None);
BEGINTIMING;
return Py_None;
}
1997-01-13 23:57:42 +01:00
static PyObject *
2000-07-10 14:04:18 +02:00
finish_timing(PyObject *self, PyObject *args)
{
1997-01-13 23:57:42 +01:00
if (!PyArg_Parse(args, ""))
return NULL;
1997-01-13 23:57:42 +01:00
ENDTIMING
Py_INCREF(Py_None);
return Py_None;
}
1997-01-13 23:57:42 +01:00
static PyObject *
2000-07-10 14:04:18 +02:00
seconds(PyObject *self, PyObject *args)
{
1997-01-13 23:57:42 +01:00
if (!PyArg_Parse(args, ""))
return NULL;
1997-01-13 23:57:42 +01:00
return PyInt_FromLong(TIMINGS);
}
1997-01-13 23:57:42 +01:00
static PyObject *
2000-07-10 14:04:18 +02:00
milli(PyObject *self, PyObject *args)
{
1997-01-13 23:57:42 +01:00
if (!PyArg_Parse(args, ""))
return NULL;
1997-01-13 23:57:42 +01:00
return PyInt_FromLong(TIMINGMS);
}
1997-01-13 23:57:42 +01:00
static PyObject *
2000-07-10 14:04:18 +02:00
micro(PyObject *self, PyObject *args)
{
1997-01-13 23:57:42 +01:00
if (!PyArg_Parse(args, ""))
return NULL;
1997-01-13 23:57:42 +01:00
return PyInt_FromLong(TIMINGUS);
}
1997-01-13 23:57:42 +01:00
static PyMethodDef timing_methods[] = {
{"start", start_timing},
{"finish", finish_timing},
{"seconds", seconds},
{"milli", milli},
{"micro", micro},
{NULL, NULL}
};
DL_EXPORT(void) inittiming(void)
{
1997-01-13 23:57:42 +01:00
(void)Py_InitModule("timing", timing_methods);
}