There are 3 aspects that make Drupal 8 more robust than WordPress code-wise: selective loading, quality, and caching. Generally the object-oriented code (OOP) is slower than the functional code, and having more code is slower than having less code. Drupal 8 has way more code than WordPress and it's OOP. So why did Drupal 8 beat WordPress by average 20% during my tests? Here's why.
1. Selective Loading.
Drupal 8 has a big code base. It integrates some of the best quality PHP libraries for it's internals, and it has lots of code. And if it would be slower, if it loaded all that code at once. But it doesn't. Object oriented programming (OOP) allows the code to be selectively loaded when they are needed for a given request. Thus, only the needed parts get loaded and ran. WordPress, being still procedural, has to load the whole code base into memory to make its functions available for being called. That's how larger code base of Drupal 8 is compensated by smart loading, allowing it to do better and more without overhead.
2. Quality of code.
You can get caching plugins for WordPress, true, but Drupal has caching out-of-the box. And Drupal's caching is way way better than WordPress caching. Why? Because to correctly cache content not only for visitors, but also for logged-in users, you need to have a smart system of triggers and checks that tell the caching system when and which cache to invalidate when the content is being edited. And second, you need to streamline the whole content data and render process through this caching system to have a good grip on it. Thus, Drupal's built-in content type and field system, together with streamlined templating system allows such caching level. WordPress, on the other hand, is architecturally incapable of supporting such level of caching, with it's markup often embedded in code, and content types and fields provided with plethora of disparate plugins, it can only bluntly cache pages for anonymous visitors (which is enough for simple sites).
We previously discussed how Drupal has a more robust data architecture. Now we have discussed how Drupal has better code. I believe that if we join the data structure and the more robust code together, we will have a general explanation of why Drupal 8 performed on average 20% faster (TTFB time) than WordPress 5 during my tests.