Why gfortran`s stream access is so slow?
- From: "CPLUSPLUS09@xxxxxxxxx" <CPLUSPLUS09@xxxxxxxxx>
- Date: Tue, 30 Oct 2007 22:25:04 -0700
Hi, everyone, i want to why gfortran`s stream read write is so slow?
default, so it should be ok while reading bytes and bytes.From gfortran`s manual, i know that gfortran`s I/O are buffered on
For testing, i wrote programs below:
----------------------------------------------C
Version---------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
if(argc!=3)
{
printf("no enought parameters!\n");
return -1;
}
FILE *srcFile,*destFile;
unsigned char byte;
int i,len;
srcFile=fopen(argv[1],"rb+");
destFile=fopen(argv[2],"wb+");
fseek(srcFile,0,SEEK_END);
len=ftell(srcFile);
printf("len=%d",len);
rewind(srcFile);
for(i=len;i>0;i--)
{
byte=fgetc(srcFile);
fputc(byte,destFile);
}
fclose(destFile);
fclose(srcFile);
return 0;
}
------------------------------------------------
GFortran--------------------------------------------
program fortCP
character(len=256) :: srcFile,destFile
character :: byte
if(command_argument_count().ne.2)then
print*,'agrument not enough!'
stop
end if
call get_command_argument(1,srcFile)
call get_command_argument(2,destFile)
open(10,file=trim(srcFile),form='unformatted',access='stream',status='old')
open(20,file=trim(destFile),form='unformatted',access='stream',status='replace')
do
read(10,end=500),byte
write(20),byte
end do
500 close(20)
close(10)
end program fortCP
--------------------------------------------------------------------------------------------------
Here`s the result.
32M File
GCC
real 0m2.925s
user 0m2.750s
sys 0m0.170s
GFORTRAN-4.2.2
real 9m48.880s
user 1m47.540s
sys 7m53.780s
export GFORTRAN_UNBUFFERED_ALL=n
real 10m0.607s
user 1m47.430s
sys 8m0.890s
export GFORTRAN_UNBUFFERED_ALL=y
real 10m1.754s
user 1m46.380s
sys 8m0.450s
Thanks every one.
.
- Follow-Ups:
- Re: Why gfortran`s stream access is so slow?
- From: glen herrmannsfeldt
- Re: Why gfortran`s stream access is so slow?
- Prev by Date: Re: opening char variable data file
- Next by Date: Stack corruption and memory leak problems in c++/Fortran application
- Previous by thread: Re: boot sector
- Next by thread: Re: Why gfortran`s stream access is so slow?
- Index(es):
Relevant Pages
|