22222

22222,第1张

22222
#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					
										


					

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5702696.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存