The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 time taken to read the information present in pipe
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ujnam

Albania
Posts

Posted - 10/28/2004 :  05:32:05 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):
Operating System:RedHat Linux 8


gettimeofday(&tv1,&tz);

if( (fp = popen("df -m .","r")) == NULL)
{
printf("Not able to execute the command 'df -m'\n");
return 2;
}
memset(&tv2,0,sizeof(tv2));
memset(&tz,0,sizeof(tz));
gettimeofday(&tv2,&tz);
printf("the time taken to execute df command is %ld - %ld = %ld\n", tv2.tv_usec, tv1.tv_usec,(tv2.tv_usec - tv1.tv_usec));

/* reading the output of the 'df -m' from the pipe */
memset(&tv1,0,sizeof(tv1));
memset(&tv2,0,sizeof(tv2));
memset(&tz,0,sizeof(tz));

gettimeofday(&tv1,&tz);

fgets(buf,sizeof(buf),fp);
memset(buf,0,sizeof(buf));
fgets(buf,sizeof(buf),fp);

memset(&tz,0,sizeof(tz));
gettimeofday(&tv2,&tz);
printf("time taken to read the information from the pipe written by popen is %ld - %ld = %ld\n",tv2.tv_usec,tv1.tv_usec,(tv2.tv_usec - tv1.tv_usec));

pclose(fp);


When the above snippet of code is embedded in one of the server coding, we get the time taken to read the information from pipe is around 9000 micro seconds, but when i run same snippet of code as a simple program, i get the time taken to read the information from the pipe about 50-60 micro seconds, can i know what might be the reason?
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000