aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/bench_bytes.zc
blob: 086d75210869dd725bbe66575454131b7d9454d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace;
include rt;

fn sumbytes(n) {
	let buf[64], i = 0, s = 0, b, reps, ch;
	while (i < 64) { buf[i] = i * 0x0101010101010101; i++; }
	b = rt.addr_b(buf);
	ch = rt.get_c();
	reps = 0;
	while (ch >= '0' && ch <= '9') { reps = reps * 10 + ch - '0'; ch = rt.get_c(); }
	while (reps > 0) {
		i = 0; s = 0;
		while (i < n) { s = s + rt.ld8(b + (i & 511)); i++; }
		reps--;
	}
	return s;
}
fn main() {
	rt.put_n(sumbytes(4000));
	rt.put_c(10);
	return 0;
}