Having done some digging around, I discovered I'm not the only one running into the 'problem' of stopStopWatch/resetStopWatch not actually doing anything with regards to the current time on the timer - it just keeps ticking up and up and up. So I'm going to be lazy now and ask in case someone knows, before I go digging:
- Will it bog my Mudlet instance down to just keep discarding/creating new ones? If I need to measure time elapsed between event a and b, then another time between event a and b, I could just make a new stopwatch every time, but is that going to fill memory up with lots of ticking intricate things, or is it just saving the system time since it was created and showing me the time elapsed every time I call the stop?
- Is there a way to delete the stopwatch?
- Is there another function that I'm missing that I could use, or are there plans to fix the resetStopWatch function? I'd very much like a way to count down and be able to see how long is left until an event - for example, a frog hops every 30 seconds. How do I periodically check if n seconds have elapsed since the last time the frog hopped, or simply see how many seconds since the last frog hop?
startStopWatch/stopStopWatch Usage Questions
Re: startStopWatch/stopStopWatch Usage Questions
The implementation is very efficient - as in, there's nothing actually ticking. It just remembers the time and gives you a delta every time you check.
1) well I'd re-use them, but you'll be find creating new ones.
2) nop
3) create a timer for 30s that resets the stopwatch, start the stopwatch - then 30 - stopwatch time will be how much is left!
1) well I'd re-use them, but you'll be find creating new ones.
2) nop
3) create a timer for 30s that resets the stopwatch, start the stopwatch - then 30 - stopwatch time will be how much is left!
Re: startStopWatch/stopStopWatch Usage Questions
Awesome, I'll just re-declare the variable then! That's the simple route, and it should work for what I need. Much appreciated.
Re: startStopWatch/stopStopWatch Usage Questions
Use this pattern to automatically re-use an existing stopwatch:
- SlySven
- Posts: 1023
- Joined: Mon Mar 04, 2013 3:40 pm
- Location: Deepest Wiltshire, UK
- Discord: SlySven#2703
Re: startStopWatch/stopStopWatch Usage Questions
"The implementation is very efficient - as in, there's nothing actually ticking." Are you sure of that Vadi? Each stopwatch uses a distinct QTime instance.
For the record, a stopwatch has a maximum period of a 23h 59m 59s and it can get things wrong if the system's clock is adjusted or - and it is something worth mentioning as I have experienced it within the last few hours - your locale's Daylight Saving Time state gets changed...
For the record, a stopwatch has a maximum period of a 23h 59m 59s and it can get things wrong if the system's clock is adjusted or - and it is something worth mentioning as I have experienced it within the last few hours - your locale's Daylight Saving Time state gets changed...
Re: startStopWatch/stopStopWatch Usage Questions
Yep I'm sure, because the line I gave only creates 1 stopwatch however many times it is called.
- SlySven
- Posts: 1023
- Joined: Mon Mar 04, 2013 3:40 pm
- Location: Deepest Wiltshire, UK
- Discord: SlySven#2703
Re: startStopWatch/stopStopWatch Usage Questions
That wasn't quite what I meant - it was more that once a stopwatch is created with createStopWatch() there is no means to subsequently destroy it in that session.
Re: startStopWatch/stopStopWatch Usage Questions
Yes, I was talking about a different kind of efficiency:
> The implementation is very efficient - as in, there's nothing actually ticking. It just remembers the time and gives you a delta every time you check.
> The implementation is very efficient - as in, there's nothing actually ticking. It just remembers the time and gives you a delta every time you check.