First of all, you should not use WordPress with PHP 8.1 as of today. It is not yet fully compatible with it; this will only be achieved with one of the next updates. One reason for slowdowns could therefore be the errors caused by PHP 8.1, which you might see with an active error login.
Furthermore, I know from my own experience a considerable difference in the performance of locally hosted sites in relation to the resources of the computer. A virtual machine on a HD is usually slower than on an SSD. The fact that this is more noticeable with WordPress than with a simple PHP file is due to the fact that WordPress itself already uses considerably more PHP functions. These in turn require more resources, including hard disk accesses, which has a corresponding effect. I once had a work PC where, thanks to a slow HD hard drive, I had an extreme loading time with fresh WordPress installations. As soon as I moved it to an SSD, it was much faster.