Benchmark : PHP eval() vs include vs inline code

Written By Sanjir Habib On Jun-3rd, 2021
Suppose a block of code. You fetched it off from database.

You have 3 options to run it.

Here's the speed test result. For the same amount of code ran 100,000 times.

0.9 sec.
Save in directory and include()
0.66 secs
0.55 secs.

So conclusion. Saveing to temporary and executing it by putting the include ""; call in a loop is just as fast as inlining it. While eval() takes double the time of both.