| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Author: George V. Neville-Neil | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | #include "Python.h"
 | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Our stuff... */ | 
					
						
							|  |  |  | #include "timing.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | start_timing(self, args) | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	if (!PyArg_Parse(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	BEGINTIMING; | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | finish_timing(self, args) | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	if (!PyArg_Parse(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	ENDTIMING     | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | seconds(self, args) | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	if (!PyArg_Parse(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	return PyInt_FromLong(TIMINGS); | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | milli(self, args) | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	if (!PyArg_Parse(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	return PyInt_FromLong(TIMINGMS); | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | micro(self, args) | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	if (!PyArg_Parse(args, "")) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	return PyInt_FromLong(TIMINGUS); | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | static PyMethodDef timing_methods[] = { | 
					
						
							|  |  |  | 	{"start",   start_timing}, | 
					
						
							|  |  |  | 	{"finish",  finish_timing}, | 
					
						
							|  |  |  | 	{"seconds", seconds}, | 
					
						
							|  |  |  | 	{"milli",   milli}, | 
					
						
							|  |  |  | 	{"micro",   micro}, | 
					
						
							|  |  |  | 	{NULL,      NULL} | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-12-04 18:50:17 +00:00
										 |  |  | DL_EXPORT(void) inittiming() | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1997-01-13 22:57:42 +00:00
										 |  |  | 	(void)Py_InitModule("timing", timing_methods); | 
					
						
							|  |  |  | 	if (PyErr_Occurred()) | 
					
						
							|  |  |  | 		Py_FatalError("can't initialize module timing"); | 
					
						
							| 
									
										
										
										
											1994-01-02 23:22:21 +00:00
										 |  |  | } |