We just wrote a CPU intensive application to benchmark Docker images. It's a Java application that approximates the decimals of Pi.
java -jar superpi.jar
it stresses all the cores and takes 30 secondsdocker run fewlaps/superpi
it stresses only two of the four cores and takes 70 secondsThe Docker image is running the .jar as we do when running it on the host. Why is the Docker image not as fast as running the .jar locally? We expected some difference between running it locally and running it on Docker, but the process takes double the time.
Is there any way to request that Docker use all the CPU?
BTW, the project is published here on GitHub: Fewlaps/SuperPI
Friends, I'm full of shame: the own MacOS Docker desktop client has a setting to enable more or less cores. Don't know if it's something added in the last version, but I didn't notice. By default, it gets two cores instead of four, which seems savvy.
Here's how the screen appears:
By the way, only for the information, on the same machine: