问题
I want to see the time of my pipe program system call. I need to measure it for analyzing results. How can i measure the time of system call in milliseconds?
For example, this is simple pipe program:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/timeb.h>
#include <time.h>
void main() {
FILE *read_fp;
char buffer[10];
int cnt;
memset(buffer,'\0',sizeof(buffer));
read_fp=popen("uname -a","|");
if (read_fp!=NULL) {
cnt=fread(buffer,sizeof(char),9,read_fp);
if (cnt>0) printf(buffer,"olololo");
pclose(read_fp);
}
}
And what is the reason of time differences, executing it more than 4 times? What's the reason of time "jumps"?
来源:https://stackoverflow.com/questions/47725553/how-to-measure-pipe-syscall-time-in-milliseconds