Solved

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

Posted on 1998-03-27
6
289 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

628 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