digitalmars.D - Get any time in milliseconds?
- Benjamin Schulte <Aldoric gmx.de> Apr 13 2008
- downs <default_357-line yahoo.de> Apr 13 2008
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Apr 13 2008
- Walter Bright <newshound1 digitalmars.com> Apr 13 2008
- Bill Baxter <dnewsgroup billbaxter.com> Apr 13 2008
- Walter Bright <newshound1 digitalmars.com> Apr 13 2008
- Bill Baxter <dnewsgroup billbaxter.com> Apr 13 2008
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Apr 13 2008
- Walter Bright <newshound1 digitalmars.com> Apr 13 2008
- Bill Baxter <dnewsgroup billbaxter.com> Apr 13 2008
- Walter Bright <newshound1 digitalmars.com> Apr 14 2008
Hi. I'm currently trying to convert my application to linux. Now I had a counter in my application that counted in milliseconds the time since the application started. I have to port this to linux. On windows I used the PerformanceCounter from the WinAPI (or the GetTickCount method, if the performance-counter is not supported). Well, I would like to have it more OS-independent or at least working somehow in linux. I tried the std.date, but actually I would have to calculate the ms-value up from the splitted values (hours, days, etc). That would be kinda complicated, cause there are too many special things. Like some month only have 30 days, sometimes 28, etc. Then I found the std.c.time clock() method, but realized, that that maybe wraps very early, cause one second is 1000000 and the value is stored in an integer. that would mean that after ~36 minutes the timer would wrap to zero (or minus something?) again. That's not helpful. So, now I'm looking for an alternate way to realize what I want. I just want ANY time counter in milliseconds. I can calculate it down to any base I want, but I just need a time~ Thanks in advance for any help
Apr 13 2008
Benjamin Schulte wrote:Hi. I'm currently trying to convert my application to linux. Now I had a counter in my application that counted in milliseconds the time since the application started. I have to port this to linux. On windows I used the PerformanceCounter from the WinAPI (or the GetTickCount method, if the performance-counter is not supported). Well, I would like to have it more OS-independent or at least working somehow in linux. I tried the std.date, but actually I would have to calculate the ms-value up from the splitted values (hours, days, etc). That would be kinda complicated, cause there are too many special things. Like some month only have 30 days, sometimes 28, etc. Then I found the std.c.time clock() method, but realized, that that maybe wraps very early, cause one second is 1000000 and the value is stored in an integer. that would mean that after ~36 minutes the timer would wrap to zero (or minus something?) again. That's not helpful. So, now I'm looking for an alternate way to realize what I want. I just want ANY time counter in milliseconds. I can calculate it down to any base I want, but I just need a time~ Thanks in advance for any help
I quote from tools.time: extern(C) { struct timeval { uint tv_sec; int tv_usec; } int gettimeofday(timeval *, void *); d_time µsec() { timeval tv = void; gettimeofday(&tv, null); return tv.tv_sec*1_000_000 + tv.tv_usec; } } Contrary to its name: and gives the number of seconds and microseconds since the Epoch (see time(2)). --man gettimeofday DESCRIPTION time() returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. --man 2 time Hope that answers your question. --downs
Apr 13 2008
"Benjamin Schulte" <Aldoric gmx.de> wrote in message news:ftst9o$sql$1 digitalmars.com...Hi. I'm currently trying to convert my application to linux. Now I had a counter in my application that counted in milliseconds the time since the application started. I have to port this to linux. On windows I used the PerformanceCounter from the WinAPI (or the GetTickCount method, if the performance-counter is not supported). Well, I would like to have it more OS-independent or at least working somehow in linux. I tried the std.date, but actually I would have to calculate the ms-value up from the splitted values (hours, days, etc). That would be kinda complicated, cause there are too many special things. Like some month only have 30 days, sometimes 28, etc. Then I found the std.c.time clock() method, but realized, that that maybe wraps very early, cause one second is 1000000 and the value is stored in an integer. that would mean that after ~36 minutes the timer would wrap to zero (or minus something?) again. That's not helpful. So, now I'm looking for an alternate way to realize what I want. I just want ANY time counter in milliseconds. I can calculate it down to any base I want, but I just need a time~ Thanks in advance for any help
std.date.getUTCtime() gives you I believe millisecond-precise time as a long (64-bit int).
Apr 13 2008
Benjamin Schulte wrote:On windows I used the PerformanceCounter from the WinAPI (or the GetTickCount method, if the performance-counter is not supported).
The last example shows how to access the hardware timer: http://www.digitalmars.com/techtips/timing_code.html
Apr 13 2008
Walter Bright wrote:Benjamin Schulte wrote:On windows I used the PerformanceCounter from the WinAPI (or the GetTickCount method, if the performance-counter is not supported).
The last example shows how to access the hardware timer: http://www.digitalmars.com/techtips/timing_code.html
What's up with std.perf? It's been in Phobos in "stealth mode" forever. Seems to work fine on Windows. Any chance it'll become official at some point? Why isn't it official now? --bb
Apr 13 2008
Bill Baxter wrote:What's up with std.perf? It's been in Phobos in "stealth mode" forever. Seems to work fine on Windows. Any chance it'll become official at some point? Why isn't it official now?
Nobody has spent the time on it.
Apr 13 2008
Walter Bright wrote:Bill Baxter wrote:What's up with std.perf? It's been in Phobos in "stealth mode" forever. Seems to work fine on Windows. Any chance it'll become official at some point? Why isn't it official now?
Nobody has spent the time on it.
Well, what's missing? Works fine on Windows, has lots of versions() for linux, so I assume it probably works there. You just need someone to say that yeh, it tests out ok? --bb
Apr 13 2008
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message news:ftts2j$2mom$1 digitalmars.com...Walter Bright wrote:Bill Baxter wrote:What's up with std.perf? It's been in Phobos in "stealth mode" forever. Seems to work fine on Windows. Any chance it'll become official at some point? Why isn't it official now?
Nobody has spent the time on it.
Well, what's missing? Works fine on Windows, has lots of versions() for linux, so I assume it probably works there. You just need someone to say that yeh, it tests out ok? --bb
AFAICT PerformanceCounter works fine on Linux. I've used it.
Apr 13 2008
Jarrett Billingsley wrote:AFAICT PerformanceCounter works fine on Linux. I've used it.
It also needs to be converted to ddoc.
Apr 13 2008
Walter Bright wrote:Jarrett Billingsley wrote:AFAICT PerformanceCounter works fine on Linux. I've used it.
It also needs to be converted to ddoc.
That's easy. I'll do that if you'll agree to put it in. --bb
Apr 13 2008
Bill Baxter wrote:Walter Bright wrote:Jarrett Billingsley wrote:AFAICT PerformanceCounter works fine on Linux. I've used it.
It also needs to be converted to ddoc.
That's easy. I'll do that if you'll agree to put it in.
How can I say no? <g>
Apr 14 2008









downs <default_357-line yahoo.de> 