- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- time precision
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2007 02:10 PM
тАО12-14-2007 02:10 PM
However this references C functions and I am not a C programmer. Does anyone know of a different way to get this level of precision or can someone write a simple C program that will use the correct C function to display the current timestamp down to the nano second?
Points will be awarded.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2007 03:20 PM
тАО12-14-2007 03:20 PM
Re: time precision
Then what do you intend to do with the
high-precision time value? Display it for a
person who can't read it in a million
nanoseconds? What's the point?
Is there some actual problem which you are
trying to solve?
Note also that precision and accuracy are not
the same thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2007 03:46 PM
тАО12-14-2007 03:46 PM
Re: time precision
It would help if you describe what you are trying to do and then more reasonable schemes might be suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2007 05:39 PM
тАО12-14-2007 05:39 PM
Re: time precision
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-14-2007 06:00 PM
тАО12-14-2007 06:00 PM
Re: time precision
> will help with the problem, [...]
That's ok. I'm not sure how the answer to
your question will help with the application.
> [...] gain some understanding on how this
> function works through a simple program.
I'd assume that it works about as documented.
Let's imagine that you have a working example
program in hand. What will you (or your
DBAs) do with it?
I can see how an event sequence number could
be useful in establishing the order of a set
of events. It's less clear to me how a
super-precise time value obtained by some
highly questionable method will do anything
useful.
> Points will be awarded.
Oh, yeah. I can see that, all right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2007 01:33 AM
тАО12-15-2007 01:33 AM
SolutionColin's procedure should work fine.
> Steven: It's less clear to me how a super-precise time value obtained by some highly questionable method will do anything useful.
Why do you think Colin's "Generating Timestamps" is questionable? Or are you reading the fine print and it seems complex to do and there is a lot of hand waving?
(I was with Colin on a customer visit when we found the problems in "Manipulating and Formatting Times".)
>can someone write a simple C program that will use the correct C function to display the current timestamp down to the nano second?
Something like this?
#include
#include
void foo() {}
struct timeval start;
int main() {
int i;
hrtime_t now, later, nano;
struct tm *p;
gettimeofday(&start, NULL);
now = gethrtime();
for (i = 0; i < 1000000; ++i)
foo();
later = gethrtime();
later -= now; // delta
printf("nano time diff: %lld\n", later);
p = localtime(&start.tv_sec);
printf("The starting time was: %.19s .%09lld secs\n",
asctime(p), start.tv_usec * 1000LL);
nano = start.tv_usec * 1000LL + later;
start.tv_sec += nano / 1000000000LL;
nano %= 1000000000LL;
p = localtime(&start.tv_sec);
printf("The starting time was: %.19s .%09lld secs\n",
asctime(p), nano);
return 0;
}
As Colin mentions, for this to work properly these two values must be known/shared among all threads/processes trying to do this timestamping
gettimeofday(&start, NULL);
now = gethrtime();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2007 05:04 AM
тАО12-15-2007 05:04 AM
Re: time precision
Thank you for the code.