Question about memcpy

bing zhu zhubohong12 at gmail.com
Sun Jul 8 10:03:48 EDT 2018


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 at 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...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180708/3bba6606/attachment.html>


More information about the Kernelnewbies mailing list