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

Q: Timer with <sec resolution

Hi all!

Each time an event happens I want to print a timestamp.
Using 'time_t' etc. works fine but it only has attributes for
an 'one second resolution'.

I tried to examine the code of Tcp-/Windump because
they have a 0.000000 second resolution. Unfortunatly I
dont really understand the code there. Could only
figure out that a 'timeval' struct from the BSD/time.h
file has been used. (which I do not have an could not download
from the www (maybe its not free anyway)

How are you programming timers with an sec.000 resolution??
A ms resulution would be fine for me :-)

THX

Jul 22 '05 #1
3 1201
Jo. Schmitt wrote:
Hi all!

Each time an event happens I want to print a timestamp.
Using 'time_t' etc. works fine but it only has attributes for
an 'one second resolution'.

I tried to examine the code of Tcp-/Windump because
they have a 0.000000 second resolution.
Shouldn't there be something other than 0 in there?
Unfortunatly I
dont really understand the code there. Could only
figure out that a 'timeval' struct from the BSD/time.h
file has been used. (which I do not have an could not download
from the www (maybe its not free anyway)

How are you programming timers with an sec.000 resolution??
A ms resulution would be fine for me :-)

THX


I don't believe there is a standard, portable way of doing this. Try a
platform-specific newsgroup. It looks like you might be using FreeBSD,
so help shouldn't be hard to find.

Good luck,
Jeff

Jul 22 '05 #2
Jo. Schmitt wrote:
Hi all!

Each time an event happens I want to print a timestamp.
Using 'time_t' etc. works fine but it only has attributes for
an 'one second resolution'.

I tried to examine the code of Tcp-/Windump because
they have a 0.000000 second resolution. Unfortunatly I
dont really understand the code there. Could only
figure out that a 'timeval' struct from the BSD/time.h
file has been used. (which I do not have an could not download
from the www (maybe its not free anyway)

How are you programming timers with an sec.000 resolution??
A ms resulution would be fine for me :-)


Well, I use QueryPerformanceCounter(), but that only works in Win32.

--
Mike Smith

Jul 22 '05 #3
> Jo. Schmitt wrote:

Each time an event happens I want to print a timestamp.
Using 'time_t' etc. works fine but it only has attributes for
an 'one second resolution'.


You can try to use Sword C++ Library.
Its "sword::Time" class has a millisecond resolution.
And it should be portable to Window and Linux (at least).

http://www.erik-n.net/sword/

Eric.
Jul 22 '05 #4

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

Similar topics

4
by: William Bub | last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second? I'm not sure if I should use the timer control, or some way to access the computer timer. I found the following site...
1
by: martinm69x | last post by:
Hey all, I've been working on the code for a kernel timer which will report real time, CPU time, user time and kernel time on the operation of fibonacci method. The way im doing it is keeping...
2
by: martin1 | last post by:
All, timer interval is 60 sec, i want ot set up timer start 15 sec later after minute. for example if current time is 2:30:00, the timer starts 2:30:15, then timer loop procedure every minute...
9
by: martin1 | last post by:
Hi, All, My question is how to set up timer start 15 sec past minute. It always start 15 sec past minute. For example, if current time is 8:30:45, the timer starts on 8:31:15 am; if current...
6
by: paresh | last post by:
Hi all, I need to set timer in C/linux like alram, such that i will get a timeout signal after specific timeout and my process remain executing as is it. I can use signal(SIGALRM, xyz) and then...
19
by: UG | last post by:
I just wanted to know whether any timer facility exists in C, as it is not mentioned in K&R 2, or in the ISO Draft. By timer function i mean that when we use standard input function like scanf() or...
11
by: =?Utf-8?B?RXJpYw==?= | last post by:
I'm coming from Win32 world. Now, I'm porting the existing code to C#. I cannot find the equivalent Win32 Waitable Timer in C#. I have a thread to perform some task periodically like following: ...
19
by: colin | last post by:
Hi, Im trying to time some parts of my code using the Stopwatch class, but it is so slow, I tried the QueryPerformanceFrequency() but this seems to be just as slow, if I just simply call this...
13
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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.