Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * File: $Id$ |
| 4 | * |
| 5 | * Author: George V. Neville-Neil |
| 6 | * |
| 7 | * Update History: $Log$ |
Guido van Rossum | cbcd8d7 | 1994-01-14 16:55:50 +0000 | [diff] [blame] | 8 | * Update History: Revision 2.2 1994/01/14 16:55:50 guido |
| 9 | * Update History: Make more robust against Minix and Mac |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 10 | * Update History: |
Guido van Rossum | cbcd8d7 | 1994-01-14 16:55:50 +0000 | [diff] [blame] | 11 | * Revision 2.1 1994/01/02 23:22:21 guido |
| 12 | * Added George Neville-Neil's timing module |
| 13 | * |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 14 | * Revision 1.1 93/12/28 13:14:39 gnn |
| 15 | * Initial revision |
| 16 | * |
| 17 | * |
| 18 | * |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef lint |
Guido van Rossum | cbcd8d7 | 1994-01-14 16:55:50 +0000 | [diff] [blame] | 23 | #ifndef THINK_C |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 24 | static char rcsid [] = "$Header$" ; |
Guido van Rossum | cbcd8d7 | 1994-01-14 16:55:50 +0000 | [diff] [blame] | 25 | #endif /* THINK_C */ |
| 26 | #endif /* lint */ |
Guido van Rossum | 116857c | 1994-01-02 23:22:21 +0000 | [diff] [blame] | 27 | |
| 28 | #include "allobjects.h" |
| 29 | #include "import.h" |
| 30 | #include "modsupport.h" |
| 31 | #include "ceval.h" |
| 32 | |
| 33 | /* Our stuff... */ |
| 34 | #include "timing.h" |
| 35 | |
| 36 | static object * |
| 37 | start_timing(self, args) |
| 38 | object *self; |
| 39 | object *args; |
| 40 | { |
| 41 | if (!getargs(args, "")) |
| 42 | return NULL; |
| 43 | |
| 44 | INCREF(None); |
| 45 | BEGINTIMING; |
| 46 | return None; |
| 47 | } |
| 48 | |
| 49 | static object * |
| 50 | finish_timing(self, args) |
| 51 | object *self; |
| 52 | object *args; |
| 53 | { |
| 54 | if (!getargs(args, "")) |
| 55 | return NULL; |
| 56 | |
| 57 | ENDTIMING |
| 58 | INCREF(None); |
| 59 | return None; |
| 60 | } |
| 61 | |
| 62 | static object * |
| 63 | seconds(self, args) |
| 64 | object *self; |
| 65 | object *args; |
| 66 | { |
| 67 | if (!getargs(args, "")) |
| 68 | return NULL; |
| 69 | |
| 70 | return newintobject(TIMINGS); |
| 71 | |
| 72 | } |
| 73 | |
| 74 | static object * |
| 75 | milli(self, args) |
| 76 | object *self; |
| 77 | object *args; |
| 78 | { |
| 79 | if (!getargs(args, "")) |
| 80 | return NULL; |
| 81 | |
| 82 | return newintobject(TIMINGMS); |
| 83 | |
| 84 | } |
| 85 | static object * |
| 86 | micro(self, args) |
| 87 | object *self; |
| 88 | object *args; |
| 89 | { |
| 90 | if (!getargs(args, "")) |
| 91 | return NULL; |
| 92 | |
| 93 | return newintobject(TIMINGUS); |
| 94 | |
| 95 | } |
| 96 | |
| 97 | |
| 98 | static struct methodlist timing_methods[] = { |
| 99 | {"start", start_timing}, |
| 100 | {"finish", finish_timing}, |
| 101 | {"seconds", seconds}, |
| 102 | {"milli", milli}, |
| 103 | {"micro", micro}, |
| 104 | {NULL, NULL} |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | void inittiming() |
| 109 | { |
| 110 | object *m; |
| 111 | |
| 112 | m = initmodule("timing", timing_methods); |
| 113 | |
| 114 | } |