PHP Performance & Benchmarking: Testing Numeric Variables

When validating numeric user input, I usually use the PHP function is_numeric(). Often though, I am really looking for an integer and not merely a numeric value. Below is the performance test of is_numeric() and is_int().

Test Environment: Linux, Apache, PHP 5.2.17.

Test Setup: Code constructs listed below. For loops used to have enough iterations to make the script execution time calculatable. Each test was run 3000 times to get the average.

Comparisons

Using is_numeric()

$var=2020;
for($i=0; $i<10000; $i++)
{
     if(is_numeric($var))
     {
          //do something
     }
}

Using is_int()

$var=2020;
for($i=0; $i<10000; $i++)
{
     if(is_int($var))
     {
          //do something
     }
}
Results
Test Avg Execution Time Comparative Graph - (longer is slower, 100% is the fastest time)
is_numeric() 8.77 ms Performance Graph 100%
is_int() 9.09 ms Performance Graph 104%