From 458120dd40db6b4df55a4e96b650e16798ef06a0 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 3 May 2011 11:25:13 +0000 Subject: add hg and python --- sys/src/cmd/python/Modules/timingmodule.c | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sys/src/cmd/python/Modules/timingmodule.c (limited to 'sys/src/cmd/python/Modules/timingmodule.c') diff --git a/sys/src/cmd/python/Modules/timingmodule.c b/sys/src/cmd/python/Modules/timingmodule.c new file mode 100644 index 000000000..56e057a65 --- /dev/null +++ b/sys/src/cmd/python/Modules/timingmodule.c @@ -0,0 +1,58 @@ +/* + * Author: George V. Neville-Neil + */ + +#include "Python.h" + +/* Our stuff... */ +#include "timing.h" + +static PyObject * +start_timing(PyObject *self) +{ + Py_INCREF(Py_None); + BEGINTIMING; + return Py_None; +} + +static PyObject * +finish_timing(PyObject *self) +{ + ENDTIMING + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +seconds(PyObject *self) +{ + return PyInt_FromLong(TIMINGS); +} + +static PyObject * +milli(PyObject *self) +{ + return PyInt_FromLong(TIMINGMS); +} + +static PyObject * +micro(PyObject *self) +{ + return PyInt_FromLong(TIMINGUS); +} + + +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}, + {NULL, NULL} +}; + + +PyMODINIT_FUNC inittiming(void) +{ + (void)Py_InitModule("timing", timing_methods); +} -- cgit v1.2.3