#include#include #include #include #include #define buf_size1 (1024*1024*10UL) #define buf_size2 (1024*1024*1024UL) #define M 100 // need struct to convert param struct Param{ char* dest; char* src; size_t n; }; void* memcpy_1(void *dest,const void *src,unsigned long l); // the benchmark void* memcpy_2(void *dest,const void *src,unsigned long l); void* memcpy_5(void *dest,const void *src,unsigned long l); void* memcpy_thread(void *dest,const void *src,unsigned long l); void* memcpy_t(void *arg); double solution(void* (*memcpy_)(void *,const void *,unsigned long)){ // 函数指针 unsigned char * buff_1; unsigned char * buff_2; unsigned long buf_size=buf_size1; buff_1 = (void *)malloc(buf_size); buff_2 = (void *)malloc(buf_size); memset(buff_1,'$',buf_size); double start,finish; start = clock(); memcpy_(buff_2,buff_1,buf_size); finish = clock(); double duration = (double)(finish - start) / CLOCKS_PER_SEC; double speed= (double) buf_size/(1024*1024)/duration; //printf( "It spends %f Seconds to memcopy %d MB n", duration, buf_size/(1024*1024)); printf( "The transfer speed %fn",speed); free(buff_1); free(buff_2); return speed; } int main(){ printf("***********the benchmark: memcpy_char_pointer one by on*************n"); double speed1=0; for(int i=0;i 欢迎分享,转载请注明来源:内存溢出
22222
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
初始C语言(2)
上一篇
2022-12-17
gdb watch 类成员变量时自动失效
下一篇
2022-12-17
评论列表(0条)