This post was published long ago, when I was a student and an amateur blogger. The links might be outdated and content may not be useful anymore. Please read this content keeping its age in mind.
Subject : System Software Laboratory
Branch : Information Science & Engineering
Semester : 6
University : VTU
[Click Here to get other programs by email ]
………………………………………………………………………………………………………………………….
PART -B
………………………………………………………………………………………………………………………….
5b) C program that accepts one command-line argument, executes the arguments as a shell command, determines the time taken by it and prints the time values, Use the “times”, function and the “tms” structure. The code need not include error checking.
#include<stdio.h>
#include<sys/times.h>
#include<unistd.h>
int main(int argc,char *argv[10])
{
char cmd[10];
struct tms obj1,obj2;
clock_t st,end;
float time;
st=times(&obj1);
system(“clear”);
printf(“%Sn”,argv[1]);
end=times(&obj2);
printf(“Real time taken = %fn”,st);
printf(“User time taken = %fn”,end);
time=(end-st)/3600;
printf(“nSystem time taken : %f”,time);
return 0;
}
Leave a ReplyCancel reply