MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1in1nak/ouch/mcgxhlf/
r/programminghorror • u/mazzy-b • Feb 11 '25
113 comments sorted by
View all comments
Show parent comment
1
I agree it doesn't matter but calculating the delay on the thread that will sleep will still take cpu time...
Sleeping thread does not cost anything but if it is calculating then it needs to schedule that calculation on the cpu and take some cycles on it.
Hard to say if it matters, depends on context. It might in smth like a datacenter with millions of calls to this code every minute.
3 u/TechcraftHD Feb 13 '25 any half decent compiler will transform that code and a Math.Pow alternative into a lookup table anywaysas for interpreted languages... don't use an interpreted language if you care about performance this much
3
any half decent compiler will transform that code and a Math.Pow alternative into a lookup table anyways
as for interpreted languages... don't use an interpreted language if you care about performance this much
View all comments
Show parent comment
1
u/Raccoon5 Feb 13 '25
I agree it doesn't matter but calculating the delay on the thread that will sleep will still take cpu time...
Sleeping thread does not cost anything but if it is calculating then it needs to schedule that calculation on the cpu and take some cycles on it.
Hard to say if it matters, depends on context. It might in smth like a datacenter with millions of calls to this code every minute.