-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctimer.C
More file actions
49 lines (38 loc) · 1.12 KB
/
ctimer.C
File metadata and controls
49 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//=========================================================================
// Name : timer
// Author : wintermute
// Version : alpha
// Copyright is gay.
// Description : a timer function
//=========================================================================
#include <Python.h>
#include <time.h>
#include <string.h>
unsigned double clock_t, flag_on, flag_off;
double elapsed;
static PyObject * // not really sure yet... tying to pass args back and forth from timer to python string constructor?
ctimer_time(PyObject *self, PyObject *args)
{
const char *command;
int sts;
if (!PyArg_ParseTuple(args, "flg", &command))
return NULL;
sts = system(command);
return Py_BuildValue("clk", sts);
}
int elapsed // working out the kinks for this method, using GNU clock
{
if (flag_match_start) // get the signal of match start
{
flag_on = clock(); // start clock
if (flag_match_end) // end cock at match close
{
flag_off = clock();
elapsed = ((double) (flag_off-flag_on)) / CLOCKS_PER_SEC;
} // calculate elpased time
}
return elapsed;
}
void turn_time()
{
if