Blame src/foo/foo.c

nsz a520c1
#include "test.h"
nsz a520c1
nsz a520c1
// dummy test
nsz a520c1
nsz 536d65
static int foo(int n) {
nsz a520c1
	int i;
nsz a520c1
nsz 072602
	for (i = 0; n > 1 && i < 100; i++) {
nsz 072602
		if (n % 2)
nsz 072602
			n = 3*n + 1;
nsz 072602
		else
nsz 072602
			n /= 2;
nsz a520c1
	}
nsz a520c1
	return n;
nsz a520c1
}
nsz a520c1
nsz fd0ee8
void test_foo() {
nsz fd0ee8
	int n = foo(123);
nsz fd0ee8
nsz fd0ee8
	if (n != 1)
nsz fd0ee8
		error("foo(123):%d expected 1\n", n);
nsz fd0ee8
}
nsz fd0ee8
nsz 7d87d3
void bench_foo(int N) {
nsz a520c1
	int i;
nsz a520c1
nsz a520c1
	for (i = 0; i < N; i++)
nsz 072602
		foo(123);
nsz a520c1
}
nsz a520c1
nsz 33761d
unsigned short ds = 12345;
nsz 33761d
unsigned short rs = 0;
nsz fd0ee8
void bench_div_short(int N) {
nsz fd0ee8
	int i;
nsz fd0ee8
nsz 33761d
	for (i = 0; i < N; i++)
nsz 33761d
		rs += (unsigned short)i/ds;
nsz fd0ee8
}
nsz fd0ee8
nsz 33761d
unsigned int di = 12345;
nsz 33761d
unsigned int ri = 0;
nsz fd0ee8
void bench_div_int(int N) {
nsz 33761d
	unsigned int i;
nsz fd0ee8
nsz 33761d
	for (i = 0; i < N; i++)
nsz 33761d
		ri += i/di;
nsz a520c1
}