aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/fbench.zc
blob: c3b7086b171442f533feafa471e9cb748c7273b1 (plain) (blame)
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
namespace;
include rt;

// float kernel, plain and o3. bench_float.sh times them. the letter picks the
// kernel and the digits are how many times to run it, same shape as bench.zc.
float poly(int n) {
	float s = 0.0;
	float x = 1.25;
	int i = 0;
	while (i < n) {
		s = s + x * 1.5;
		x = x * 0.5 + 1.0;
		i = i + 1;
	}
	return s;
}
o3 float poly3(int n) {
	float s = 0.0;
	float x = 1.25;
	int i = 0;
	while (i < n) {
		s = s + x * 1.5;
		x = x * 0.5 + 1.0;
		i = i + 1;
	}
	return s;
}
fn main() {
	let which = rt.get_c(), reps = 0, ch = rt.get_c(), r = 0;
	while (ch >= 48 && ch <= 57) { reps = reps * 10 + ch - 48; ch = rt.get_c(); }
	while (reps > 0) {
		if (which == 97) r = (int)poly(20000);
		if (which == 98) r = (int)poly3(20000);
		if (which == 99) r = (int)poly(2000);
		reps = reps - 1;
	}
	rt.put_n(r);
	rt.put_c(10);
	return 0;
}