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
|
|
|
{
|
2010-05-09 11:46:46 -03: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
|
|
|
{
|
2010-05-09 11:46:46 -03: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
|
|
|
{
|
2010-05-09 11:46:46 -03: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
|
|
|
{
|
2010-05-09 11:46:46 -03: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
|
|
|
{
|
2010-05-09 11:46:46 -03: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[] = {
|
2010-05-09 11:46:46 -03: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},
|
|
|
|
{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)
|
2016-09-17 04:54:55 -03:00
|
|
|
return;
|
2010-05-09 11:46:46 -03:00
|
|
|
|
|
|
|
(void)Py_InitModule("timing", timing_methods);
|
1994-01-02 19:22:21 -04:00
|
|
|
}
|