Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Modules / timingmodule.c
blobbbccb43bce920857597310c9479374274b9eaf72
1 /*
2 * Author: George V. Neville-Neil
3 */
5 #include "Python.h"
7 /* Our stuff... */
8 #include "timing.h"
10 static PyObject *
11 start_timing(self, args)
12 PyObject *self;
13 PyObject *args;
15 if (!PyArg_Parse(args, ""))
16 return NULL;
18 Py_INCREF(Py_None);
19 BEGINTIMING;
20 return Py_None;
23 static PyObject *
24 finish_timing(self, args)
25 PyObject *self;
26 PyObject *args;
28 if (!PyArg_Parse(args, ""))
29 return NULL;
31 ENDTIMING
32 Py_INCREF(Py_None);
33 return Py_None;
36 static PyObject *
37 seconds(self, args)
38 PyObject *self;
39 PyObject *args;
41 if (!PyArg_Parse(args, ""))
42 return NULL;
44 return PyInt_FromLong(TIMINGS);
48 static PyObject *
49 milli(self, args)
50 PyObject *self;
51 PyObject *args;
53 if (!PyArg_Parse(args, ""))
54 return NULL;
56 return PyInt_FromLong(TIMINGMS);
59 static PyObject *
60 micro(self, args)
61 PyObject *self;
62 PyObject *args;
64 if (!PyArg_Parse(args, ""))
65 return NULL;
67 return PyInt_FromLong(TIMINGUS);
72 static PyMethodDef timing_methods[] = {
73 {"start", start_timing},
74 {"finish", finish_timing},
75 {"seconds", seconds},
76 {"milli", milli},
77 {"micro", micro},
78 {NULL, NULL}
82 DL_EXPORT(void) inittiming()
84 (void)Py_InitModule("timing", timing_methods);
85 if (PyErr_Occurred())
86 Py_FatalError("can't initialize module timing");