-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathbench.c
More file actions
52 lines (36 loc) · 713 Bytes
/
bench.c
File metadata and controls
52 lines (36 loc) · 713 Bytes
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
47
48
49
50
51
/*
bench.c
2020-11-18
Public Domain
http://abyz.me.uk/lg/lgpio.html
gcc -Wall -o bench bench.c -llgpio
./bench
*/
#include <stdio.h>
#include <stdlib.h>
#include <lgpio.h>
#define LFLAGS 0
#define OUT 21
#define LOOPS 20000
int main(int argc, char *argv[])
{
int h;
int i;
double t0, t1;
h = lgGpiochipOpen(0);
if (h >= 0)
{
if (lgGpioClaimOutput(h, LFLAGS, OUT, 0) == LG_OKAY)
{
t0 = lguTime();
for (i=0; i<LOOPS; i++)
{
lgGpioWrite(h, OUT, 0);
lgGpioWrite(h, OUT, 1);
}
t1 = lguTime();
printf("%.0f toggles per second\n", (1.0 * LOOPS)/(t1-t0));
}
lgGpiochipClose(h);
}
}