- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: time in milliseconds _ Urgent help required
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
тАО05-24-2004 06:37 PM
тАО05-24-2004 06:37 PM
I need to find the time in milliseconds using c functions . I need to do something like this
timenow=msecond(&time);
//some actions//
timafter=msecond(&time);
Please help me as this is knida urgent
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2004 07:05 PM
тАО05-24-2004 07:05 PM
SolutionJust use a macro to convert the output of this function into milliseconds.. here's an example:
#define msecond(&timer) ((gettimeofday(&timer,&dont_care)) ? -1.0 : ((float)(timer.tv_sec * 1000) + (timer.tv_usec/1000) ))
Just subtract timenow from timeafter to get the diff in ms
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2004 11:58 PM
тАО05-24-2004 11:58 PM
Re: time in milliseconds _ Urgent help required
call clock 1st
run the code
call clock again it will give you the difference in microseconds.
man clock
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2004 12:10 AM
тАО05-25-2004 12:10 AM
Re: time in milliseconds _ Urgent help required
#include
#include
#include
main()
{
int tim1,tim2;
struct timeval tp1,tp2;
struct timezone tzp;
tim1=gettimeofday(&tp1,&tzp);
(void) usleep(200000); /* 200ms */
tim2=gettimeofday(&tp2,&tzp);
printf("first time : %d %d : %d\n",tim1,tp1.tv_sec,tp1.tv_usec);
printf("second time : %d %d : %d\n",tim2,tp2.tv_sec,tp2.tv_usec);
}
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2004 01:18 PM
тАО05-25-2004 01:18 PM
Re: time in milliseconds _ Urgent help required
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2004 08:07 PM
тАО05-25-2004 08:07 PM
Re: time in milliseconds _ Urgent help required
struct timeval now;
struct timezone timezone;
gettimeofday(&now,&timezone);
/* now.tv_sec is seconds since EPOCH
(1/1/1970 00:00:00) */
/* now.tv_usec is microseconds in the current second */
do a man on "gettimeofday" and have a look in the time.h include file for more info and details of the structures.
Note: Microseconds are not always accurate to the microsecond - there is some small error involved in the CPU calculating this. However, it would be insignificant in the calculation of milliseconds from microseconds. This error can be significant in calculation of timestamps for things like auditing software or flight simulations etc.
Enjoy
Rossco