473,406 Members | 2,404 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,406 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 8896
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.