digitalmars.D - Get any time in milliseconds?
- Benjamin Schulte (9/9) Apr 13 2008 Hi.
- downs (24/37) Apr 13 2008 I quote from tools.time:
- Jarrett Billingsley (4/24) Apr 13 2008 std.date.getUTCtime() gives you I believe millisecond-precise time as a ...
- Walter Bright (3/5) Apr 13 2008 The last example shows how to access the hardware timer:
- Bill Baxter (5/12) Apr 13 2008 What's up with std.perf? It's been in Phobos in "stealth mode" forever....
- Walter Bright (2/5) Apr 13 2008 Nobody has spent the time on it.
- Bill Baxter (6/12) Apr 13 2008 Well, what's missing?
- Jarrett Billingsley (3/15) Apr 13 2008 AFAICT PerformanceCounter works fine on Linux. I've used it.
- Walter Bright (2/3) Apr 13 2008 It also needs to be converted to ddoc.
- Bill Baxter (3/7) Apr 13 2008 That's easy. I'll do that if you'll agree to put it in.
-
Walter Bright
(2/9)
Apr 14 2008
How can I say no?
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 helpI 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 helpstd.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: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? --bbOn 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
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: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? --bbWhat'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
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message news:ftts2j$2mom$1 digitalmars.com...Walter Bright wrote:AFAICT PerformanceCounter works fine on Linux. I've used it.Bill Baxter wrote: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? --bbWhat'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
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:That's easy. I'll do that if you'll agree to put it in. --bbAFAICT PerformanceCounter works fine on Linux. I've used it.It also needs to be converted to ddoc.
Apr 13 2008
Bill Baxter wrote:Walter Bright wrote:How can I say no? <g>Jarrett Billingsley wrote:That's easy. I'll do that if you'll agree to put it in.AFAICT PerformanceCounter works fine on Linux. I've used it.It also needs to be converted to ddoc.
Apr 14 2008