1
votes

I am reviewing code which creates a lot of threads. CreateThread documentation on Windows says that a all thread creation calls are serialized within a process. To estimate the performance impact of such code, I wonder how long does CreateThread take to run? I understand this depends on the number of DLLs already loaded into the process, but would like to know a ballpark value.

Thanks!

1

1 Answers

2
votes

Your best bet may be to write a unit test and see how long it takes for your application.

But, if you need a large number of threads, then while your program is starting up, in the initialization, you could spawn a thread that just starts to fill in an array of threads, so you can finish setting up your application and the threads will be ready when they are needed.

If I give numbers from my laptop, it will differ based on OS, processor, ram and perhaps .net version, so the numbers will be very rough at best.