July 8, 2018
2:03 p.m.
void *p = malloc(4096 * max); start = usec(); for (i = 0; i < max; i++) { memcpy(p + i * 4096, page, 4096); } end = usec(); printf("%s : %d time use %lu us \n", __func__, max,end - start); static unsigned long usec(void) { struct timeval tv; gettimeofday(&tv, 0); return (unsigned long)tv.tv_sec * 1000000 + tv.tv_usec; } I'm don't think it's really precise but i did notice a difference , 2018-07-08 2:44 GMT+08:00 <valdis.kletnieks@vt.edu>:
On Sat, 07 Jul 2018 19:36:47 +0800, bing zhu said:
and in user space i do the same thing,I noticed that kernel is faster than user ,
How did you measure the times? Doing this right is actually harder than it looks...