[help] os.clock() different behavior with Linux-Mac or Windows???


(Raul (ulneiz)) #1

I have a question about the os.clock()

I am using os.clock() with Windows in a tool. I have read here that os.clock() has a different behavior in Linux or Mac different than with Windows.

So, if you program a script using os.clock() and tested with Windows , will it behave differently with Linux or Mac?

Basically, I have built a panel that blinks and then disappears after a short period of time. I have used os.clock () and add_timer () with Windows.Is there a problem using os.clock () in the 3 operating systems? Will he have a different behavior?Unfortunately I can not test it on Linux or Mac.

Thanks!


(joule) #2

Interesting. I didn’t know that… Seems to be a real show stopper for a lot of things, if it’s true. (Things like pulsating button colors… or recording things in your own “sequencer” to a buffer).

Surely, the Renoise devs must have modified this behavior to make it consistent?


(danoise) #3

Nope, this is a pain in a lot of places but not the Renoise API.

Here is what the docs have to say about it:

-- Replaced with a high precision timer (still expressed in milliseconds)
os.clock() -> [number]

(Raul (ulneiz)) #4

Nope, this is a pain in a lot of places but not the Renoise API.

Here is what the docs have to say about it:

-- Replaced with a high precision timer (still expressed in milliseconds)
os.clock() -> [number]

Perfect, thank you very much!I was really concerned about this issue.Then we can program with os.clock() and add_timer() / remove_timer() without having to worry about the operating system. Great!

Another question about os.clock() …

I understand that os.clock () automatically restarts after several seconds have elapsed. Is it necessary to stop it (restart it beforehand) or do something special?

If you need to register a period of 7 seconds with os.clock(), and at that moment it restarts automatically, an unexpected behavior could be returned? It would be unusual, a coincidence. But could it happen?

How long does it take os.clock () to restart automatically?