| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include "Python.h" |
| 6 |
|
| 7 |
|
| 8 |
#include "timing.h" |
| 9 |
|
| 10 |
static PyObject * |
| 11 |
start_timing(PyObject *self) |
| 12 |
{ |
| 13 |
Py_INCREF(Py_None); |
| 14 |
BEGINTIMING; |
| 15 |
return Py_None; |
| 16 |
} |
| 17 |
|
| 18 |
static PyObject * |
| 19 |
finish_timing(PyObject *self) |
| 20 |
{ |
| 21 |
ENDTIMING |
| 22 |
Py_INCREF(Py_None); |
| 23 |
return Py_None; |
| 24 |
} |
| 25 |
|
| 26 |
static PyObject * |
| 27 |
seconds(PyObject *self) |
| 28 |
{ |
| 29 |
return PyInt_FromLong(TIMINGS); |
| 30 |
} |
| 31 |
|
| 32 |
static PyObject * |
| 33 |
milli(PyObject *self) |
| 34 |
{ |
| 35 |
return PyInt_FromLong(TIMINGMS); |
| 36 |
} |
| 37 |
|
| 38 |
static PyObject * |
| 39 |
micro(PyObject *self) |
| 40 |
{ |
| 41 |
return PyInt_FromLong(TIMINGUS); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
static PyMethodDef timing_methods[] = { |
| 46 |
{"start", (PyCFunction)start_timing, METH_NOARGS}, |
| 47 |
{"finish", (PyCFunction)finish_timing, METH_NOARGS}, |
| 48 |
{"seconds", (PyCFunction)seconds, METH_NOARGS}, |
| 49 |
{"milli", (PyCFunction)milli, METH_NOARGS}, |
| 50 |
{"micro", (PyCFunction)micro, METH_NOARGS}, |
| 51 |
{NULL, NULL} |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
PyMODINIT_FUNC inittiming(void) |
| 56 |
{ |
| 57 |
if (PyErr_WarnPy3k("the timing module has been removed in " |
| 58 |
"Python 3.0; use time.clock() instead", 2) < 0) |
| 59 |
return; |
| 60 |
|
| 61 |
(void)Py_InitModule("timing", timing_methods); |
| 62 |
} |