栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

22222

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/702590.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号