6 static struct thread_data {
10 static void *worker(void *data)
12 struct thread_data *td = data;
18 size = td->mib * 1024UL * 1024UL;
21 for (i = 0; i < 100000; i++) {
22 for (index = 0; index + 4096 < size; index += 4096)
23 memset(&buf[index+512], 0x89, 512);
25 printf("loop%d: did %lu MiB\n", i+1, size/(1024UL*1024UL));
32 int main(int argc, char *argv[])
34 unsigned long mib, threads;
39 printf("%s: <MiB per thread> <threads>\n", argv[0]);
43 mib = strtoul(argv[1], NULL, 10);
44 threads = strtoul(argv[2], NULL, 10);
46 pthreads = calloc(threads, sizeof(pthread_t));
49 for (i = 0; i < threads; i++)
50 pthread_create(&pthreads[i], NULL, worker, &td);
52 for (i = 0; i < threads; i++) {
55 pthread_join(pthreads[i], &ret);