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
Solved

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

Posted on 1998-03-27
6
274 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
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

809 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