三个模式传输的问题,请高手指教(上)

chengpeng820921 2003-12-28 05:25:28
求救,请大虾帮帮小弟,小弟这个程序老是得不到我要的结果,
这个程序的功能是看三个模式下文件的传输速度。source,source_1...source_9
这几个文件要自已建,自己任意用一个文件改名即可。源代码如下
#include<iostream.h>
#include<windows.h>
void filter_nobuffer(char *source,char *sink,void(*func)(char *addr));
void filter_sequen(char *source,char *sink,void(*func)(char *addr));
void filter_overlp(char *source,char *sink,void(*func)(char *addr));

void f1(char *addr);
void f2(char *addr);
void f3(char *addr);
void f4(char *addr);
void f5(char *addr);

#define BUFFER_SIZE 1024
char *buffer;

void main()
{buffer=new char[BUFFER_SIZE];

DWORD tick;

DWORD nobuffer_average_time=0;
DWORD sequen_average_time=0;
DWORD overlp_average_time=0;

cout<<"无文件高速缓存模式正在运行..."<<endl;
DWORD nobuffer_start_time=GetTickCount();
DWORD nobuffer_end_time=GetTickCount();

tick=nobuffer_start_time;
filter_nobuffer("source.txt","nobuffer_1.txt",f1);
cout<<"nobuffer 0-1:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_1.txt","nobuffer_2.txt",f2);
cout<<"nobuffer 1-2:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_2.txt","nobuffer_3.txt",f3);
cout<<"nobuffer 2-3:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_3.txt","nobuffer_4.txt",f4);
cout<<"nobuffer 3-4:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_4.txt","nobuffer_5.txt",f5);
cout<<"nobuffer 4-5:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_5.txt","nobuffer_6.txt",f1);
cout<<"nobuffer 5-6:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_6.txt","nobuffer_7.txt",f2);
cout<<"nobuffer 6-7:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_7.txt","nobuffer_8.txt",f3);
cout<<"nobuffer 7-8:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_8.txt","nobuffer_9.txt",f4);
cout<<"nobuffer 8-9:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_nobuffer("source_9.txt","nobuffer_10.txt",f5);
cout<<"nobuffer 9-10:"<<GetTickCount() - tick<<"ms."<<endl;


cout<<"使用高速缓存模式正在运行..."<<endl;

DWORD sequen_start_time=GetTickCount();
DWORD sequen_end_time=GetTickCount();

tick=sequen_start_time;
filter_sequen("source.txt","sequen_1.txt",f1);
cout<<"sequen 0-1:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_1.txt","sequen_2.txt",f2);
cout<<"sequen 1-2:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_2.txt","sequen_3.txt",f3);
cout<<"sequen 2-3:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_3.txt","sequen_4.txt",f4);
cout<<"sequen 3-4:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_4.txt","sequen_5.txt",f5);
cout<<"sequen 4-5:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_5.txt","sequen_6.txt",f1);
cout<<"sequen 5-6:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_6.txt","sequen_7.txt",f2);
cout<<"sequen 6-7:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_7.txt","sequen_8.txt",f3);
cout<<"sequen 7-8:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_8.txt","sequen_9.txt",f4);
cout<<"sequen 8-9:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_sequen("source_9.txt","sequen_10.txt",f5);
cout<<"sequen 9-10:"<<GetTickCount() - tick<<"ms."<<endl;


cout<<"异步传输模式正在运行..."<<endl;

DWORD overlp_start_time=GetTickCount();
DWORD overlp_end_time=GetTickCount();

tick=overlp_start_time;
filter_overlp("source.txt","sequen_1.txt",f1);
cout<<"overlp 0-1:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_1.txt","sequen_2.txt",f2);
cout<<"overlp 1-2:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_2.txt","sequen_3.txt",f3);
cout<<"overlp 2-3:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_3.txt","sequen_4.txt",f4);
cout<<"overlp 3-4:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_4.txt","sequen_5.txt",f5);
cout<<"overlp 4-5:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_5.txt","sequen_6.txt",f1);
cout<<"overlp 5-6:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_6.txt","sequen_7.txt",f2);
cout<<"overlp 6-7:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_7.txt","sequen_8.txt",f3);
cout<<"overlp 7-8:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_8.txt","sequen_9.txt",f4);
cout<<"overlp 8-9:"<<GetTickCount() - tick<<"ms."<<endl;

tick=GetTickCount();
filter_overlp("source_9.txt","sequen_10.txt",f5);
cout<<"overlp 9-10:"<<GetTickCount() - tick<<"ms."<<endl;


...全文
183 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,643

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧