473,385 Members | 1,409 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,385 software developers and data experts.

how to get the time in usec

Dear all,

I would like to get the time on how long to run a short segment of my
c program in usec under Windows platform using dev-c++. Is there any
method or function call to get it other than using clock()?

Thank you very much.

Regards,
Jacky
Nov 13 '05 #1
4 9859

"JackyMove" <mo**********@hotmail.com> wrote in message news:b9**************************@posting.google.c om...
Dear all,

I would like to get the time on how long to run a short segment of my
c program in usec under Windows platform using dev-c++. Is there any
method or function call to get it other than using clock()?

Thank you very much.

Regards,
Jacky


getrusage ()
http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?getrusage
http://www.opengroup.org/onlinepubs/...getrusage.html

-------------------------------------------------------------------------------------
http://www.hgmp.mrc.ac.uk/cgi-bin/ma...opic=getrusage
<QUOTE>
ru_utime The total amount of time spent executing in user
mode. Time is given in seconds and microseconds.

ru_stime The total amount of time spent executing in system
mode. Time is given in seconds and microseconds.
</QUOTE>
-------------------------------------------------------------------------------------

--
=====================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
=====================================

Nov 13 '05 #2
JackyMove wrote:
Dear all,

I would like to get the time on how long to run a short segment of my
c program in usec under Windows platform using dev-c++. Is there any
method or function call to get it other than using clock()?

Thank you very much.

Regards,
Jacky

clock() is the closest thing in standard C. I don't know what dev-c++ is,
but it's surely off topic. You could count CPU clock ticks. Look up rdtsc.
--
Tim Prince
Nov 13 '05 #3
mo**********@hotmail.com (JackyMove) writes:
I would like to get the time on how long to run a short segment of my
c program in usec under Windows platform using dev-c++. Is there any
method or function call to get it other than using clock()?


Not in standard C, but I'm sure there are Windows-specific functions
that do what you want. Try a Windows-specific newsgroup.

--
Keith Thompson (The_Other_Keith) ks*@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 13 '05 #4
In article <Dj*******************@newssvr21.news.prodigy.com> ,
ti***********@xxxxsbcglobal.net says...
clock() is the closest thing in standard C. I don't know what dev-c++ is,
but it's surely off topic. You could count CPU clock ticks. Look up rdtsc.


Unfortunately, according to Intel there is no guarantee that rdtsc will
give you useful data on a SMP system, as the rdtsc result is not
synchronized between CPUs. If your process gets bumped to another CPU,
your results will be WAY off. This used to be good advice (if you didn't
mind not being portable off of some x86 CPUs), but with SMP systems
becoming increasingly common, it's horribly broken now. If you're using
a broken thread implementation (I.e. one which lets you pin a thread to a
physical CPU) then it might be useful for you, but only if the code gets
called from a single thread. For conventional processes, forget about it.

Nov 13 '05 #5

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

Similar topics

10
by: point | last post by:
Hi... I have this format 2003-12-01 18:46:20.0 And would like it to be 01-12-2003 18:46:20 I know it can be done vis string cuts and explodes but ther's got to be a better way using time...
0
by: mcorrea | last post by:
There is any way to get the total load time of a page when you get an "IFRAME" on it? In all the tests, I got only the base page time without the "IFRAME" time.... <?php $bench = new...
4
by: simon | last post by:
Hi, I have a fairly complicated script that seems to load fairly fast. But that's because it is on my local server in the office and not on the main one, (and I am the only one on it). So I...
1
by: AaronV | last post by:
Hello, I'd like to get the time it took a query to execute. Is there a PHP or MySQL function that would return the execute-time of the query into a useable format? Similar to the way Google...
3
by: sarmin kho | last post by:
Hi Pythoners, i have been using a lot of global variables in the python script i am working on. the global variables are shared and used by all various 'definitions' : def name (): global all...
3
by: Fuzzyman | last post by:
I want to parse some text and generate an output that is similar but not identical to the input. The string I produce will be of similar length to the input string - but a bit longer. I'm...
1
by: MyHaz | last post by:
What is the running time of conactination on character strings. i.e. >> joe="123" >> joe+="99999999999999999" is it Amortized Constant time? I don't think it would be O((number of...
1
by: jisrar | last post by:
Hi, I have written two algorithms and need to be compare them in terms of how long each take. I have tried clock() before/after each algorithm but my CLOCKS_PER_SEC variable is defined as 1000...
3
by: youtoo | last post by:
It has been extensively discussed the time complexity (quadratic) of string concatenation (due to string's immutability). But what is: == the time complexity of string indexing? Is it constant?...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.