473,401 Members | 2,139 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,401 software developers and data experts.

function c++ to calculate microseconds

I search a function to calculate microseconds in a time istant
Jan 22 '08 #1
3 8895
On Jan 22, 5:17*am, Francesco <francesco.meli...@gmail.comwrote:
I search a function to calculate microseconds in a time istant
use clock() and CLOCKS_PER_SEC

for example, the following should give you the interval in ms from
when the first line was executed

int t = clock();
...
cout << "in ms " << ((static_cast<float>(t)/CLOCKS_PER_SEC)*1000);

Jan 22 '08 #2
On Jan 22, 6:06*am, JoeC...@gmail.com wrote:
On Jan 22, 5:17*am, Francesco <francesco.meli...@gmail.comwrote:
I search a function to calculate microseconds in a time istant

use clock() and CLOCKS_PER_SEC

for example, the following should give you the interval in ms from
when the first line was executed

int t = clock();
...
cout << "in ms " << ((static_cast<float>(clock()-t)/
CLOCKS_PER_SEC)*1000);

sorry...correction
Jan 22 '08 #3
Jo*****@gmail.com wrote:
On Jan 22, 5:17 am, Francesco <francesco.meli...@gmail.comwrote:
>I search a function to calculate microseconds in a time istant

use clock() and CLOCKS_PER_SEC
Note, however, that it's in no way guaranteed that the value returned
by clock() has microsecond resolution. The value may well increase eg.
in steps of 1/10 of a millisecond or whatever.

I'm not even sure it's possible in all systems to get clock values
with microsecond resolution (the hardware/OS may limit this).
Jan 22 '08 #4

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

Similar topics

1
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
1
by: beavenour | last post by:
I am looking for some help creating a more universal function out of this lame attempt at javascript. I have little experience with javascript and want to be able to universalize this function. ...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
51
by: Richard Hengeveld | last post by:
Hi all, I'm trying to understand how pointers for function parameters work. As I understand it, if you got a function like: void f(int *i) { *i = 0; }
1
by: Ahmed Fat-hi | last post by:
I need function that generates simple tone with frequency 1562.5 HZ to be played on the audio device for duration 1920 microseconds. i can not use the Beep function since it has the following...
2
by: Michael Evans | last post by:
First, we rely on a stable update rate so that our physics and dynamics calculations and integrations are based on a known interval and therefore are true-to-life. Second, the graphics positions...
3
by: NiteshR | last post by:
Hi, Does anyoe know how to call the F9 key function (Calculate Sheet) using C#? Thanks.
4
by: lenygold via DBMonster.com | last post by:
I found this example in MYSQL: create table events ( id integer not null primary key , datetime_start datetime not null , datetime_end datetime not null ); insert into events values ( 1,...
1
by: miked13 | last post by:
I have 4 textfields labeled "qtyA","qtyB","qtyC" and "GrandTotal". I have my calculate() function run Onchange of any of the "qty" fields and it displays it in "GrandTotal". I am trying to get my...
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: 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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.