1994-01-02 19:22:21 -04:00
|
|
|
/*
|
|
|
|
* Author: George V. Neville-Neil
|
|
|
|
*/
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
#include "Python.h"
|
1994-01-02 19:22:21 -04:00
|
|
|
|
|
|
|
/* Our stuff... */
|
|
|
|
#include "timing.h"
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyObject *
|
2002-03-31 10:57:24 -04:00
|
|
|
start_timing(PyObject *self)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
1997-01-13 18:57:42 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
BEGINTIMING;
|
|
|
|
return Py_None;
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyObject *
|
2002-03-31 10:57:24 -04:00
|
|
|
finish_timing(PyObject *self)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
1997-01-13 18:57:42 -04:00
|
|
|
ENDTIMING
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyObject *
|
2002-03-31 10:57:24 -04:00
|
|
|
seconds(PyObject *self)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
1997-01-13 18:57:42 -04:00
|
|
|
return PyInt_FromLong(TIMINGS);
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyObject *
|
2002-03-31 10:57:24 -04:00
|
|
|
milli(PyObject *self)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
1997-01-13 18:57:42 -04:00
|
|
|
return PyInt_FromLong(TIMINGMS);
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|
2002-03-31 10:57:24 -04:00
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyObject *
|
2002-03-31 10:57:24 -04:00
|
|
|
micro(PyObject *self)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
1997-01-13 18:57:42 -04:00
|
|
|
return PyInt_FromLong(TIMINGUS);
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
static PyMethodDef timing_methods[] = {
|
2002-03-31 10:57:24 -04:00
|
|
|
{"start", (PyCFunction)start_timing, METH_NOARGS},
|
|
|
|
{"finish", (PyCFunction)finish_timing, METH_NOARGS},
|
|
|
|
{"seconds", (PyCFunction)seconds, METH_NOARGS},
|
|
|
|
{"milli", (PyCFunction)milli, METH_NOARGS},
|
|
|
|
{"micro", (PyCFunction)micro, METH_NOARGS},
|
1997-01-13 18:57:42 -04:00
|
|
|
{NULL, NULL}
|
1994-01-02 19:22:21 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-01 23:27:13 -03:00
|
|
|
PyMODINIT_FUNC inittiming(void)
|
1994-01-02 19:22:21 -04:00
|
|
|
{
|
2008-05-12 00:47:47 -03:00
|
|
|
if (PyErr_WarnPy3k("the timing module has been removed in "
|
|
|
|
"Python 3.0; use time.clock() instead", 2) < 0)
|
|
|
|
return;
|
|
|
|
|
1997-01-13 18:57:42 -04:00
|
|
|
(void)Py_InitModule("timing", timing_methods);
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|