soulhealer Posted January 18, 2008 Posted January 18, 2008 (edited) hi, i wonder if there is a better way, because this takes a lot of memory and CPU: $timeinMs = 358735672;ms, for example. $hour = Floor($timeinMs / 3600);this define the hours $minute = Floor(($timeinMs - ($hour * 3600)) / 60);this define the minutes $second = $timeinMs - ( $hour * 3600 ) - ( $minute * 60 );this define the seconds it takes a lot of memory to refresh the transformation in every seconds, which means, it counts that way every seconds. is there a better & shorter way? thanks. Edited January 18, 2008 by soulhealer
Siao Posted January 18, 2008 Posted January 18, 2008 (edited) I don't think the above code is the cause of your high CPU usage. Even on my pretty old PC, it runs in ~0.1 ms. Which means there are unused 999.9 ms in every second for something else. Which means that either you're repeating the above code way more often than you should, or something else is the problem. Btw, for these calculations to be correct, the total time ($timeinMs) should be in seconds, not milliseconds, of course. I suppose that's a typo? Edited January 18, 2008 by Siao "be smart, drink your wine"
soulhealer Posted January 18, 2008 Author Posted January 18, 2008 I don't think the above code is the cause of your high CPU usage.Even on my pretty old PC, it runs in ~0.1 ms. Which means there are unused 999.9 ms in every second for something else.Which means that either you're repeating the above code way more often than you should, or something else is the problem.Btw, for these calculations to be correct, the total time ($timeinMs) should be in seconds, not milliseconds, of course. I suppose that's a typo?yeah, it should be in seconds, i mistyped it thanks anyway for noticing my thread.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now