Solved

clock tics-based code profiling in C with SCO3.0,  How?

Posted on 1998-03-27
6
251 Views
Last Modified: 2010-04-21
I want to be able to measure execution performance of some
code in SCO3.0 (Unix Ver V, rel 3.2). I want to do it in C if possible. I want to get measure before code segment, get
measure after segment, take the difference, and convert to
seconds (or fraction of). I don't necessarily need measure
in tics, as long as result is in subseconds. Ideas would be
greatly appreciated.
0
Comment
Question by:tclot
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#include <time.h>
time_t  start, finish;
time(&start);

code segment();

time(&finish);
printf("%f\n", difftime(finish, start));
0
 

Author Comment

by:tclot
Comment Utility
ozo,
thanks for the response. When I do what you suggest, start and finish are in seconds, not tics. So when I take the difference, its always zero unless the code segment takes longer than 1 second. If you have any other ideas would be greatly appreciated.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
You might try

for( i=0; i<1000; i++ ){ code segment(); }

or

#include <sys/types.h>
#include <sys/times.h>
struct tms buffer;
times (&buffer);
ticks=buffer.tms_utime;

or

#include  <sys/types.h>
#include  <sys/timeb.h>
#include  <time.h>
struct timeb tp[1];
ftime (tp);
ticks= tp->millitm;

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:tclot
Comment Utility
ozo,
Thanks! The third option worked (using struct timeb). I want to award you the points, but not sure how to since you added a comment instead of an answer. I'll figure it out... Thanks again.
0
 

Author Comment

by:tclot
Comment Utility
ozo,
if you resend your last comment as an answer, I can reward you the 100 points.
0
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
Comment Utility
#include  <sys/types.h>
#include  <sys/timeb.h>
#include  <time.h>
struct timeb tp[1];
ftime (tp);
ticks= tp->time*1000+tp->millitm;
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now