cpython/Modules/timingmodule.c

59 lines
952 B
C
Raw Normal View History

/*
* Author: George V. Neville-Neil
*/
1997-01-13 18:57:42 -04:00
#include "Python.h"
/* Our stuff... */
#include "timing.h"
1997-01-13 18:57:42 -04:00
static PyObject *
start_timing(PyObject *self)
{
1997-01-13 18:57:42 -04:00
Py_INCREF(Py_None);
BEGINTIMING;
return Py_None;
}
1997-01-13 18:57:42 -04:00
static PyObject *
finish_timing(PyObject *self)
{
1997-01-13 18:57:42 -04:00
ENDTIMING
Py_INCREF(Py_None);
return Py_None;
}
1997-01-13 18:57:42 -04:00
static PyObject *
seconds(PyObject *self)
{
1997-01-13 18:57:42 -04:00
return PyInt_FromLong(TIMINGS);
}
1997-01-13 18:57:42 -04:00
static PyObject *
milli(PyObject *self)
{
1997-01-13 18:57:42 -04:00
return PyInt_FromLong(TIMINGMS);
}
1997-01-13 18:57:42 -04:00
static PyObject *
micro(PyObject *self)
{
1997-01-13 18:57:42 -04:00
return PyInt_FromLong(TIMINGUS);
}
1997-01-13 18:57:42 -04:00
static PyMethodDef timing_methods[] = {
{"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}
};
PyMODINIT_FUNC inittiming(void)
{
1997-01-13 18:57:42 -04:00
(void)Py_InitModule("timing", timing_methods);
}