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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 time taken to read the information present in pipe

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ujnam Posted - 10/28/2004 : 05:32:05 AM
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?

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000