projects
/
libc-test
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
bench: pass N as argument, update readme
[libc-test]
/
src
/
foo
/
foo.c
1
#include "test.h"
2
3
// dummy test
4
5
static int foo(int n) {
6
int i;
7
8
for (i = 0; n > 1 && i < 100; i++) {
9
if (n % 2)
10
n = 3*n + 1;
11
else
12
n /= 2;
13
}
14
return n;
15
}
16
17
void bench_foo(int N) {
18
int i;
19
20
for (i = 0; i < N; i++)
21
foo(123);
22
}
23
24
void test_foo() {
25
int n = foo(123);
26
27
if (n != 1)
28
error("foo(123):%d expected 1\n", n);
29
}