Solved

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

Posted on 1998-03-27
6
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

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

code segment();

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

Author Comment

by:tclot
ID: 2009046
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
ID: 2009047
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tclot
ID: 2009048
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
ID: 2009049
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
ID: 2009050
#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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

749 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