~kris/9p

9hist

ref: dce0b3ea5e6472bf9439edd32b33623e28cf6e91 9hist/mpc/memspeed.c -rw-r--r-- 781 bytes
dce0b3ea — David du Colombier Plan 9 from Bell Labs 2000-07-18 26 years ago
                                                                                
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
52
53
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"

char	d0[1000008], d1[1000008];

static void	test(int size, int align);


void
memspeed()
{
	int j;

	spllo();

	memmove(d0, d1, sizeof(d0));
	
	for(j = 0; j<8; j++)
		test(12, j);
	for(j = 0; j<8; j++)
		test(100, j);
	for(j = 0; j<8; j++)
		test(400, j);
	for(j = 0; j<8; j++)
		test(1000, j);
	for(j = 0; j<8; j++)
		test(10000, j);
	for(j = 0; j<8; j++)
		test(100000, j);
	for(j = 0; j<8; j++)
		test(1000000, j);
}

static void
test(int size, int align)
{
	int n;
	int t;

	t = -TK2MS(m->ticks);
	n = 10000000/size;
	while(n) {
		memmove(d0+align, d1, size);
		n--;
	}
	t += TK2MS(m->ticks);
	print("size = %d align = %d KB/s %d %d\n", size, align, 10000000/t, t);
}