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

ctime Help

Hello:

I am trying to find documentation on using the ctime library as I need
to be able to instantiate an object to keep track of the time when a
certain event occurs. I also need to be able to take two of those
objects and perform calculations on them like: the time difference,
summing them, getting the mean time between events, etc.

Is ctime what I should be using?
Is there a better way?
Is there an clock or counter object that would act as a stopwatch and
continually run from instantiation while other code is executing?

I am trying to write a simulation program for a class project and I
have to calculate the time between events, but I am not sure how to go
about using some kind of timing object.

If you have any suggestions, I would appreciate them. I am not asking
anyone to write the program for me, just give me some direction as to
help me avoid mistakes and inefficient coding.

Thank you in advance.

Kevin
Jul 22 '05 #1
3 2400
On 15 May 2004 18:48:17 -0700, ke****@digimindz.com (Kevin) wrote:
Hello:

I am trying to find documentation on using the ctime library as I need
to be able to instantiate an object to keep track of the time when a
certain event occurs. I also need to be able to take two of those
objects and perform calculations on them like: the time difference,
summing them, getting the mean time between events, etc.

Is ctime what I should be using?
Is there a better way?
Is there an clock or counter object that would act as a stopwatch and
continually run from instantiation while other code is executing?

I am trying to write a simulation program for a class project and I
have to calculate the time between events, but I am not sure how to go
about using some kind of timing object.

If you have any suggestions, I would appreciate them. I am not asking
anyone to write the program for me, just give me some direction as to
help me avoid mistakes and inefficient coding.

Thank you in advance.


If you snarf any version of my InitUtil library from
http://www.bdsoft.com/tools/initutil.html
you'll find it comes packaged with a header file full of nifty STL
utilities (written by Scott Meyers, who has kindly given me permission to
distribute it). Among them is a simple little "Timer" class that let's you
query how much time has elapsed since each instance has been instantiated.
You may get some useful techniques/ideas from that. It is even fairly
portable.
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #2
Ian
Kevin wrote:
Hello:

I am trying to find documentation on using the ctime library as I need
to be able to instantiate an object to keep track of the time when a
certain event occurs. I also need to be able to take two of those
objects and perform calculations on them like: the time difference,
summing them, getting the mean time between events, etc.

Is ctime what I should be using?
Is there a better way?
Is there an clock or counter object that would act as a stopwatch and
continually run from instantiation while other code is executing?
ctime and friends only work in seconds, so if you require more accuracy,
you will have to use a platform specific API to read the system time.

It also depends on whether you want a periodic wakeup, or to time based
on other external events.

All platforms will have a methods of implementing stopwatch type
functionality - post to a group for your platform for information on how
to do this.
I am trying to write a simulation program for a class project and I
have to calculate the time between events, but I am not sure how to go
about using some kind of timing object.
Sounds like you will require a hi-res timer? If so this will be
platform specific.

If you're not sure where to look, post back with your platform and
someone will point yo in the right direction.

Ian
If you have any suggestions, I would appreciate them. I am not asking
anyone to write the program for me, just give me some direction as to
help me avoid mistakes and inefficient coding.

Thank you in advance.

Kevin

Jul 22 '05 #3
Kevin writes:
I am trying to find documentation on using the ctime library as I need
to be able to instantiate an object to keep track of the time when a
certain event occurs. I also need to be able to take two of those
objects and perform calculations on them like: the time difference,
summing them, getting the mean time between events, etc.

Is ctime what I should be using?
Is there a better way?
Is there an clock or counter object that would act as a stopwatch and
continually run from instantiation while other code is executing?

I am trying to write a simulation program for a class project and I
have to calculate the time between events, but I am not sure how to go
about using some kind of timing object.

If you have any suggestions, I would appreciate them. I am not asking
anyone to write the program for me, just give me some direction as to
help me avoid mistakes and inefficient coding.


If I understand the question, you don't want ctime or any of its kin. As I
understand it you are writing a simulator, so the program *simulates* the
passing of time. ctime has to do with real time in the real world, not
simulated time in a simulated world. A simulation program creates and
controls its own time and advances it if, as and when it thinks necessary.
Like so:

double timex = 0.0; // Because the identifier "time" may be already used
by the system.

An advance of 1.0 might mean one picosecond or one year. It's up to you,
you own it.
Jul 22 '05 #4

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

Similar topics

1
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h...
5
by: berkay | last post by:
long num,num1; char *first; char *last; num=ilk.getTime();//gets time first=ctime(&num); cout.flush(); fflush(stdin); 1) cout<<"first:"<<first;
2
by: Hao Xu | last post by:
Hi everyone! I think that everyone knows ctime() in glibc: The ctime(), gmtime() and localtime() functions all take an argument of data type time_t which represents calendar time. When ...
2
by: Chris | last post by:
Hello, How can i convert a C++ CTime (4 bytes) into a C# DateTime ? (my CTime is read in a file). Thanks, -- Chris
8
by: B Williams | last post by:
I have been searching the internet trying to find the definition for the function time() in the standard library header <ctime>. Can someone help me with this? Thanks in advance.
4
by: Gary Wessle | last post by:
Hi I am not getting current time with this program, what am I doing wrong? #include <ctime> #include <iostream> using namespace std; #define P(x) cout << #x " = " << (x) << "\n";
11
by: aisling.cronin | last post by:
Hi I am using ctime to convert the following string 1144412677847 .... Please could some one to double check if they get the same result as me (The Time is Sun Nov 02 09:11:51 2031). It seems...
4
by: Pietro Cerutti | last post by:
Hi group, #include <stdio.h> #include <unistd.h> #include <time.h> int main(void) { time_t t1, t2; char *st1, *st2;
0
by: qpwang | last post by:
Dear All, I got a problem and need your help. After I converted my project (Embedded VC++ 3.0 for Pocket PC) to .NET 2005 Framework I can compile it without any error or warning. Then I ran it on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.