473,388 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

the time of the routine

Hi people,
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund.
Thanks!

Feb 7 '06 #1
7 1850

"Romulo Carneiro" <ro***********@gmail.com> schreef in bericht
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi people,
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund.
Thanks!


You should then take a look at time.h header file

Arne
Feb 7 '06 #2
Romulo Carneiro said:
Hi people,
I wonder how I can calculate how much time any routine spend?


Use a profiler.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Feb 7 '06 #3

"Romulo Carneiro" <ro***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund[sic].


Why do you want to do this in C (or C++)? The minimum resolution for C time
function will be much larger than the time spent in the C routine unless you
do something to slow down your code. Your best choice would be assembly.
For Intel cpu's, you'll need the 'rdtsc' instruction.
Rod Pemberton



Feb 8 '06 #4
"Rod Pemberton" <do*******@bitbucket.cmm> writes:
"Romulo Carneiro" <ro***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund[sic].


Why do you want to do this in C (or C++)? The minimum resolution for C time
function will be much larger than the time spent in the C routine unless you
do something to slow down your code. Your best choice would be assembly.
For Intel cpu's, you'll need the 'rdtsc' instruction.


In C, the time() function measures real time (using the type time_t),
and the clock() function measures CPU time (using the type clock_t).
The standard doesn't define the resolution of either function. time()
typically has a resolution of 1 second; clock()'s resolution is
typically better. (The result returned by clock() is scaled by
CLOCKS_PER_SEC; this doesn't necessarily indicate the actual
resolution.)

Even if you need better resolution than time() and clock() can
provide, there's seldom any need to resort to assembly language.
There are plenty of system-specific timing routines (consult your
documentation or, if that fails, a system-specific newsgroup for
details). You could also use a profiler if your system provides one.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 8 '06 #5
On 2006-02-08, Rod Pemberton <do*******@bitbucket.cmm> wrote:

"Romulo Carneiro" <ro***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund[sic].


Why do you want to do this in C (or C++)? The minimum resolution for C time
function will be much larger than the time spent in the C routine


Easy to say, given that among the absolutely nothing that the standard
says about time_t is included absolutely nothing about its resolution.

[Elsewhere, it also says nothing about the amount of time spent in any C
routine]
Feb 8 '06 #6

"Jordan Abel" <ra*******@gmail.com> wrote in message
news:sl***********************@random.yi.org...
On 2006-02-08, Rod Pemberton <do*******@bitbucket.cmm> wrote:

"Romulo Carneiro" <ro***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund[sic].


Why do you want to do this in C (or C++)? The minimum resolution for C time function will be much larger than the time spent in the C routine


Easy to say, given that among the absolutely nothing that the standard
says about time_t is included absolutely nothing about its resolution.

[Elsewhere, it also says nothing about the amount of time spent in any C
routine]


Exactly, _nothing_ is guaranteed for time_t or clock_t. It could be large.
It could be small. But, when one is approaching 4Ghz (4 with 9 zeros) for
desktop CPU's, and faster even for mini-frames or main-frames, it's very
likely it won't be small enough. In which case, he'll need a CPU
instruction or a high-speed hardware clock. If he is using a PC, Intel's
rdtsc, Read Time-Stamp Counter Instruction, is 64-bits in size and
_guaranteed_ to increment by one for every CPU clock. The same or similar
would be true of a high-speed hardware clock. Calling a system function to
do the same thing that one or a few assembly instructions can do with much
less overhead doesn't make any sense in this situation, at least to me. I'm
not about to ignore reality, mathematics, or history, just because it isn't
in _the_ specification somewhere.
Rod Pemberton
Feb 9 '06 #7
Jordan Abel <ra*******@gmail.com> writes:
On 2006-02-08, Rod Pemberton <do*******@bitbucket.cmm> wrote:
"Romulo Carneiro" <ro***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I wonder how I can calculate how much time any routine spend?
I 'd like to get date format minute and secund[sic].
Why do you want to do this in C (or C++)? The minimum resolution for C time
function will be much larger than the time spent in the C routine


Easy to say, given that among the absolutely nothing that the standard
says about time_t is included absolutely nothing about its resolution.


It's not *quite* absolutely nothing. time_t is guaranteed to be an
arithmetic type capable of representing times. Nothing is said about
*how* it represents times; it needn't even be a linear or monotonic
mapping. But it can't be, for example, a pointer or a structure.
[Elsewhere, it also says nothing about the amount of time spent in any C
routine]


Actually, it says nothing in the same section.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one...
10
by: fabio de francesco | last post by:
Hi what do you think of the following? Why are we permitted to do that? And why the C++ Library doesn't stop someone willing to perfom that assignement (*a = 20)? #include <iostream> ...
1
by: Ronny Sigo | last post by:
Hello all, I have a table which has 30 memofields each containing a text. (Approx. 1/2 page). Depending on various situations these texts are sent via e-mail. When the time comes to send text nr...
14
by: George | last post by:
In Time.h there is a structure defined for time settings. I'm building an embedded system that has a Real Time Clock but it's not PC compatible. My question is: I don't some elements of the...
17
by: Franc Zabkar | last post by:
My D-Link DSL-302G modem/router has a real-time clock whose settings are volatile. To avoid hand keying the date/time via the modem's JS interface, I wonder if there is a way to copy the JS code to...
1
by: Martin123456 | last post by:
Hi, yes i am new to VB6 , and i would like some help. i would like to compare the computer time with a list of times that i have pre stored, ie. at 14:15 goto routine at 14:20 goto routine ...
21
by: Bob Darlington | last post by:
I have a routine which checks idle time and opens a pop up screen to advise users before shutting them down. The pop up has an option for the user to keep the application open, in which case the...
0
by: Hendrik van Rooyen | last post by:
Lawrence D'Oliveiro wrote: The above is an endless loop, doing something every five seconds, and something else in the in between times. I don't think you are dense - its a good point,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.