home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Modules / timingmodule.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  1.1 KB  |  76 lines

  1. /*
  2.  * Author: George V. Neville-Neil
  3.  */
  4.  
  5. #include "Python.h"
  6.  
  7. /* Our stuff... */
  8. #include "timing.h"
  9.  
  10. static PyObject *
  11. start_timing(PyObject *self, PyObject *args)
  12. {
  13.     if (!PyArg_Parse(args, ""))
  14.         return NULL;
  15.  
  16.     Py_INCREF(Py_None);
  17.     BEGINTIMING;
  18.     return Py_None;
  19. }
  20.  
  21. static PyObject *
  22. finish_timing(PyObject *self, PyObject *args)
  23. {
  24.     if (!PyArg_Parse(args, ""))
  25.         return NULL;
  26.  
  27.     ENDTIMING    
  28.     Py_INCREF(Py_None);
  29.     return Py_None;
  30. }
  31.  
  32. static PyObject *
  33. seconds(PyObject *self, PyObject *args)
  34. {
  35.     if (!PyArg_Parse(args, ""))
  36.         return NULL;
  37.  
  38.     return PyInt_FromLong(TIMINGS);
  39.  
  40. }
  41.  
  42. static PyObject *
  43. milli(PyObject *self, PyObject *args)
  44. {
  45.     if (!PyArg_Parse(args, ""))
  46.         return NULL;
  47.  
  48.     return PyInt_FromLong(TIMINGMS);
  49.  
  50. }
  51. static PyObject *
  52. micro(PyObject *self, PyObject *args)
  53. {
  54.     if (!PyArg_Parse(args, ""))
  55.         return NULL;
  56.  
  57.     return PyInt_FromLong(TIMINGUS);
  58.  
  59. }
  60.  
  61.  
  62. static PyMethodDef timing_methods[] = {
  63.     {"start",   start_timing},
  64.     {"finish",  finish_timing},
  65.     {"seconds", seconds},
  66.     {"milli",   milli},
  67.     {"micro",   micro},
  68.     {NULL,      NULL}
  69. };
  70.  
  71.  
  72. DL_EXPORT(void) inittiming(void)
  73. {
  74.     (void)Py_InitModule("timing", timing_methods);
  75. }
  76.