向外部共享文件的主机做IO读写,能造成网络流量吗?
使用网络映射磁盘访问外部共享,请问能造成网络流量吗?//####################################################################
// #
//随机读取10m,20mk,30m,40m,50mk,把之写入1亿个文件中的随机一个文件 #
// #
//####################################################################
Action()
{
const int waittime = 1;
char string;
char dest_filename;
char source_filename;
long dest_stream,source_stream;
int count;
char *buffer;
char *directory="z:\\"; //是我映射的外部共享,到本地的Z盘。要向里面写入数据。
char *directory1="d:\\R710\\data\\10m50m\\"; //是本地磁盘,里面是读的源数据
int n=1;
int m=1;
//int f;
int y,w,z;//后缀
//int w;
int c;
int filename,filename1;
lr_message("begin");
srand(time(NULL));
while(n!=0)
{
y=rand()%5;
w=rand()%201;
filename=(rand()%899) +100;
filename1=rand()%5;
z=rand()%12;
sprintf(dest_filename,"%s%d\\0\\000\\%d\\%d", directory,y,w,filename);
sprintf(dest_filename,"%s%s%d",dest_filename,".",z);
sprintf(source_filename,"%s%d", directory1,filename1);
lr_output_message(source_filename);
lr_output_message(dest_filename);
if(access(source_filename,0)==0) //file exist
{
source_stream = fopen(source_filename,"rb");
if(!source_stream)
lr_output_message("unable to open source");
dest_stream = fopen(dest_filename,"wb");
if(dest_stream && source_stream)
{
if((buffer = (char *)malloc(buffer_size * sizeof(char))) == NULL) {
lr_output_message("Insufficient memory available");
return -1;
}c=0;
while (!feof(source_stream))
{
count = fread(buffer, sizeof(char), iosize, source_stream);
c=c+count;
fwrite(buffer,count,1,dest_stream);
lr_output_message("%3d bytes write", c);
}
free(buffer);
fclose(dest_stream);
fclose(source_stream);
}
else {
sprintf(string,"can't open dest: %s",dest_filename);
lr_output_message(string);
}
}
else
{
sprintf(string,"file %s does not exist",source_filename);
lr_output_message(string);
}
n--;
}
//lr_think_time(waittime);
return 0;
}
读写也正常,Z盘被找到的那个文件被覆盖,也有写的统计,结果:
Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
begin
Action.c(43): d:\R710\data\10m50m\3
Action.c(44): z:\0\0\000\15\318.0
Action.c(64): 32768 bytes write
Action.c(64): 65536 bytes write
Action.c(64): 98304 bytes write
……
我再观察网络流量,发现带宽没有上去,不知这种方式对外部共享主机的IO造成流量不?这方法可不可行?
请大虾们指点。
[ 本帖最后由 zenglei 于 2010-7-22 11:45 编辑 ] 应该有带宽吧,你看看网卡自己的流量监控 你的Z盘是通过网络映射的,在它上面更新文件就肯定会有流量 原帖由 云层 于 2010-7-21 12:17 发表 http://bbs.51testing.com/images/common/back.gif
应该有带宽吧,你看看网卡自己的流量监控
是的,这个没问题了。是有流量的,方法可行。
页:
[1]