Now is the time 00: 01: 23.5856140
The speed of this program is determined by the bandwidth of RAM on your computer. This is a permanent design and is not related to processor speed. RAM plays a role here due to the very large number of digits in the factorial, they no longer fit the processor caches. And the BigInteger multiplication memory access pattern is very unfriendly, all digits must multiply the number.
Your program takes 57 seconds on my laptop, I know that it has PC3-12800 RAM. Which has a maximum transfer rate of 12800 MB / s, gives or takes CAS latency (I do not know). Thus, we can calculate the speed of RAM on your and your machine:
1:23 = 83 s, 57/83 x 12800 = 8790 MB / s.
Which is a pretty close match for the PC3-8500. The frequency of RAM is very common on white-box machines that you received from a manufacturer like Dell. Your friend, fast PC, a little toaster, gently lay it out :)
Fwiw, why a highly-supported post doesnβt have a big effect on speed can also use an explanation. The console window used by your program belongs to a different process. Conhost.exe, you can see it on the Processes tab of Taskman.exe. He takes care of scrolling and painting the window, under the hood, your program uses the interaction process to tell him to refresh the window.
This happens when your program is running in a different thread, so your program only gets bogged down when it launches Conhost.exe, sending updates faster than it can handle. So, at the beginning of your program, you are still fast and bogged down. But not when the number of digits begins to increase, and your multiplications begin to slow down. In general, the slowdown is not so great.
source share