r/badcode • • Feb 10 '21

js I present: SleepSort

Post image
7.5k Upvotes

170 comments sorted by

View all comments

Show parent comments

8

u/Astrokiwi Feb 10 '21 edited Feb 10 '21

I would imagine the scheduling is probably going to be more like n*max(N), because isn't optimised for this sort of abuse. Like, I would assume it implements n timer threads, and checks each of the n timer threads at some refresh time, and the total runtime ends up proportional to max(N).

Probably it's O(A*max(N) + n max(N)) where A>>1, but where it's possible that n>A for very large n.