xlsgen 4.9 introduces a multithreaded calculation engine.
xlsgen multithreaded calculation engine can be taken advantage of to accelerate calculations or just avoid having many CPU cores staying idle. Here is a snapshot of a calculation scenario using single thread calculations :
 Single thread calculations (notice the 24% overall usage and the bottom right chart) |
And here is the same calculation scenario with all of the 6 CPU cores of that i5-9400 taken to handle the calculations :
 Mlutithread calculations (notice the 100% overall usage and all charts) |
The amount of worker threads is up to the client application. Of course, if you are running a CPU with n cores, it makes sense to create no more than n worker threads otherwise threads will be waiting one another, not doing work in parallel.
If you don't know how many cores the CPU where
xlsgen runs has, it can be queried very easily :
| C/C++ code |
int nbCores = workbook->CalculationOptions->MultithreadCores;
|
And then, creating n worker threads for next calculations is just as simple :
| C/C++ code |
workbook->CalculationOptions->MultithreadCores = n;
workbook->CalculateFormulas();
|