www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/29/20:39:06

Xref: news2.mv.net comp.os.msdos.djgpp:1567
From: Tzekih Tsai <mbsfptt AT afs DOT mcc DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: How to obtain CPU time (of a subroutine) within a C/C++ program?
Date: 29 Feb 1996 14:07:26 GMT
Organization: Sirius Cybernetics Corporation
Lines: 19
Message-ID: <4h4buu$spj@yama.mcc.ac.uk>
NNTP-Posting-Host: cguhpa.cgu.mcc.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello,
  I know this is not a DJGPP specific question but I thought some other people
might be interested in the answer as well, ie. if someone can provide one.  I
already tried a post to comp.unix.questions, only got one answer, asked me to
use getrusage, can't find it on my system.
  The basic question is how to get CPU run time (not wall time) of a
subroutine? Obviously, I would like to do this within the main program.  At the
moment I just use a unix command time to get the CPU usage of my program.  Does
anybody has any ideas how this can be done?  I am using GCC2.7.0 on HP-UX
A.09.03 system.
  Or someone can point me to the source in which gprof get the CPU time for
each subroutine.  I have look at some of the source for gprof, it is kind of
heavy going for me.  Also I think the timing of the subroutine is not done in
gprof, rather it is done by gcc with its -pg options.  I am kind of lost in
tracking down the timing routine in gcc.  Please help.
  Thanks in advance.
-- 
TzeKih Tsai

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019