Is their a method in c++ or c that gives me the system time in
milliseconds or higher resolution? I need it to be platform
independent. Today I use timeGetTime which is windows specific.
thanks 8 6796
"marcus" <ma************ @koping.net> wrote in message
news:1a******** *************** ***@posting.goo gle.com...
| Is their a method in c++ or c that gives me the system time in
| milliseconds or higher resolution? I need it to be platform
| independent. Today I use timeGetTime which is windows specific.
The resolution is implementation dependant AFAIK.
Check out the following macros to determine what you can achieve:
CLK_TCK
CLOCKS_PER_SEC
Cheers,
Chris Val
#include <ctime>
timeval tv;
struct timezone tz;
gettimeofday(&t v, &tz);
Refer to a online help for further information.
-Chris
"marcus" <ma************ @koping.net> schrieb im Newsbeitrag
news:1a******** *************** ***@posting.goo gle.com... Is their a method in c++ or c that gives me the system time in milliseconds or higher resolution? I need it to be platform independent. Today I use timeGetTime which is windows specific.
thanks
Christian Meier wrote: #include <ctime>
timeval tv; struct timezone tz; gettimeofday(&t v, &tz);
Refer to a online help for further information.
Doesn't compile on my machine. And online help doesn't help either.
What's 'timeval'? What's 'timezone'? What's 'gettimeofday'? I don't
see those in the Standard anywhere? Are they ANSI/ISO C++? -Chris
"marcus" <ma************ @koping.net> schrieb im Newsbeitrag news:1a******** *************** ***@posting.goo gle.com...
Is their a method in c++ or c that gives me the system time in millisecond s or higher resolution? I need it to be platform independent . Today I use timeGetTime which is windows specific.
thanks
V
Don't know if it is in the standard. If you don't know it, then it is not.
But perhaps it helps for marcus' problem.
It works at least on SUN Solaris, IBM AIX and Linux.
"Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag
news:rG******** *********@newsr ead1.mlpsca01.u s.to.verio.net. .. Christian Meier wrote: #include <ctime>
timeval tv; struct timezone tz; gettimeofday(&t v, &tz);
Refer to a online help for further information.
Doesn't compile on my machine. And online help doesn't help either. What's 'timeval'? What's 'timezone'? What's 'gettimeofday'? I don't see those in the Standard anywhere? Are they ANSI/ISO C++?
-Chris
"marcus" <ma************ @koping.net> schrieb im Newsbeitrag news:1a******** *************** ***@posting.goo gle.com...
Is their a method in c++ or c that gives me the system time in millisecond s or higher resolution? I need it to be platform independent . Today I use timeGetTime which is windows specific.
thanks
V
On 19 Apr 2005 05:21:59 -0700, marcus
<ma************ @koping.net> wrote: Is their a method in c++ or c that gives me the system time in milliseconds or higher resolution? I need it to be platform independent. Today I use timeGetTime which is windows specific.
There is nothing platform-independent because there is nothing in the
standard which says that a platform even has a timer at all. The time()
and clock() functions may return -1 to indicate that they aren't
implemented.
Best is to write a separate module of your own which you can then
implement specifically for particular platforms, the rest of your code
then doesn't need to bother about it.
Chris C
Christian Meier wrote: "Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag news:rG******** *********@newsr ead1.mlpsca01.u s.to.verio.net. .. Christian Meier wrote: "marcus" <ma************ @koping.net> schrieb im Newsbeitrag news:1a******** *************** ***@posting.goo gle.com...
Is their a method in c++ or c that gives me the system time in millisecond s or higher resolution? I need it to be platform independent . Today I use timeGetTime which is windows specific.
#include <ctime>
timeval tv; struct timezone tz; gettimeofday(&t v, &tz);
Refer to a online help for further information.
Doesn't compile on my machine. And online help doesn't help either. What's 'timeval'? What's 'timezone'? What's 'gettimeofday'? I don't see those in the Standard anywhere? Are they ANSI/ISO C++?
Don't know if it is in the standard. If you don't know it, then it is not. But perhaps it helps for marcus' problem. It works at least on SUN Solaris, IBM AIX and Linux.
gettimeofday is part of the POSIX standard, but isn't part of the C or
C++ standards.
You might try a cross-platform library such as:
- boost (see http://www.boost.org/doc/html/date_time.html ),
- ACE (see http://www.cs.wustl.edu/~schmidt/ACE.html ), etc.
which should be able to use the right time API on each platform.
HTH,
Simon.
From http://msdn.microsoft.com/library/de.../_crt_time.asp
"The time function returns the number of seconds elapsed since midnight
(00:00:00), January 1, 1970, coordinated universal time, according to
the system clock."
That sounds like what you're looking for. The time() function is
standard.
On 19 Apr 2005 11:55:33 -0700, jo******@gmail. com
<jo******@gmail .com> wrote: From http://msdn.microsoft.com/library/de.../_crt_time.asp
"The time function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock."
On a Microsoft system. Or on a POSIX one possibly (the POSIX standard
says that the time is returned in seconds "since the Epoch", which is
not necessarily 1970).
That sounds like what you're looking for. The time() function is standard.
But what it returns isn't:
7.23.2.5 The time function
Synopsis
1 #include <time.h>
time_t time(time_t *timer);
Description
2 The time function determines the current calendar time. The encoding
of the value is unspecified.
time_t is an "arithmetic type capable of representing times", but there
is no guarantee that it is even linear (it could be bit fields in a
structure with year, month, day, hours, minutes, seconds and jiffies for
instance) or even an integer (a double precision number in Julian days
with a fractional component, for example).
For that matter, time(NULL) might return (time_t)-1 as a constant value
if the calendar time isn't available, even POSIX doesn't guarantee that
it is available.
Chris C This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Griffiths |
last post by:
Here is a report I've written about a printing problem that is being
experienced by a particular company for whom I had developed a A97 system.
After upgrading to Win XP and AXP, some printing problems have arisen. My
investigations show that it is not related to the particular system I
developed. but is affecting Access in general. So, has nothing to do with
reports being set to print to a default printer (which they all are) or to a...
|
by: Steve |
last post by:
Can anyone tell me the preferred method for writing and
retrieving persistent information using .Net.
Specifically, I am referring to information that you used
to see in registry keys or .ini files like the name of a
database or connection string.
I have read several articles indicating that .config files
are now used, but I am confused because they are read-
only. If I want to write information from within the
application (When a...
|
by: GTDriver |
last post by:
I would like to know if there is function in VB.NET that returns the date and
time someone last turned on/off the computer? I'm more interested in knowing
this on a non-networked computer. Maybe there is already an .exe in the
windows operating system that performs this task.
How can I get the above requested info?
--
Sincerely,
|
by: Sakke |
last post by:
Hello!
We have written a GCryptoSvr.dll COM server in C++. Inside that resides
WebClient COM component. WebClient CLSID is
{8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that WebClient
COM component from C++ code it works just fine. However when we try to
use that same WebClient in the same machine with following C# code:
using GCRYPTOSVRLib;
WEBClient WC = new WEBClient();
|
by: Susanne Klemm |
last post by:
Hello!
I use a procedure to insert a new row into a table with an identity
column. The procedure has an output parameter which gives me the
inserted identity value. This worked well for a long time. Now the
identity value is over 700.000 and I get errors whiles retrieving the
inserted identitiy value. If I delete rows and reset the identity
everything works well again. So I think it is a data type problem.
My Procedure:
| |
by: jimmyfo |
last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published
(using VS2005 Publish feature) it to a relatively clean machine with
ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create
my SQL connection in the code-behind, I get the following error. I
tried to register the DLL using regsvr32 but that errored out saying,
"dllregisterserver entry point was not found". Any ideas?
Retrieving the COM class factory...
|
by: Madmartigan |
last post by:
Hello
I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors?? (using Dev-C++ compiler)
Please see task and attempt below:
TASK : 1.8.1 Exercise 1A - Temperature tracker
Write a program that tracks temperatures during an experiment that takes 24 hours. The user should input the temperature. This...
|
by: Sanjay Pais |
last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time
using the with - over clauses
In query analyser, the data is retrieved in under a second.
When retrieving using the data adaptor.fill or datareader to retrieve the
data it takes over 24 seconds.
public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int
PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime
DateEnd, int status,...
|
by: shirleylouis |
last post by:
Hi Ppl, Could anyone help me out with retrieving URL from Clipboard
using C#??
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |