Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 1 | /* |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 2 | * Author: George V. Neville-Neil |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 3 | */ |
| 4 | |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 5 | #include "allobjects.h" |
| 6 | #include "import.h" |
| 7 | #include "modsupport.h" |
| 8 | #include "ceval.h" |
| 9 | |
| 10 | /* Our stuff... */ |
| 11 | #include "timing.h" |
| 12 | |
| 13 | static object * |
| 14 | start_timing(self, args) |
| 15 | object *self; |
| 16 | object *args; |
| 17 | { |
| 18 | if (!getargs(args, "")) |
| 19 | return NULL; |
| 20 | |
| 21 | INCREF(None); |
| 22 | BEGINTIMING; |
| 23 | return None; |
| 24 | } |
| 25 | |
| 26 | static object * |
| 27 | finish_timing(self, args) |
| 28 | object *self; |
| 29 | object *args; |
| 30 | { |
| 31 | if (!getargs(args, "")) |
| 32 | return NULL; |
| 33 | |
| 34 | ENDTIMING |
| 35 | INCREF(None); |
| 36 | return None; |
| 37 | } |
| 38 | |
| 39 | static object * |
| 40 | seconds(self, args) |
| 41 | object *self; |
| 42 | object *args; |
| 43 | { |
| 44 | if (!getargs(args, "")) |
| 45 | return NULL; |
| 46 | |
| 47 | return newintobject(TIMINGS); |
| 48 | |
| 49 | } |
| 50 | |
| 51 | static object * |
| 52 | milli(self, args) |
| 53 | object *self; |
| 54 | object *args; |
| 55 | { |
| 56 | if (!getargs(args, "")) |
| 57 | return NULL; |
| 58 | |
| 59 | return newintobject(TIMINGMS); |
| 60 | |
| 61 | } |
| 62 | static object * |
| 63 | micro(self, args) |
| 64 | object *self; |
| 65 | object *args; |
| 66 | { |
| 67 | if (!getargs(args, "")) |
| 68 | return NULL; |
| 69 | |
| 70 | return newintobject(TIMINGUS); |
| 71 | |
| 72 | } |
| 73 | |
| 74 | |
| 75 | static struct methodlist timing_methods[] = { |
| 76 | {"start", start_timing}, |
| 77 | {"finish", finish_timing}, |
| 78 | {"seconds", seconds}, |
| 79 | {"milli", milli}, |
| 80 | {"micro", micro}, |
| 81 | {NULL, NULL} |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | void inittiming() |
| 86 | { |
| 87 | object *m; |
| 88 | |
| 89 | m = initmodule("timing", timing_methods); |
| 90 | |
| 91 | } |