Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demo of finfo performance in php 7.2 vs 7.3
#!/bin/bash
set -e
ITERS=${1:-1000}
echo "Testing finfo over $ITERS iterations"
for VER in '7.2' '7.3'; do
echo ---
echo "Testing PHP $VER"
docker run -i \
-e "ITERS=${ITERS}" \
php:${VER}-cli-alpine php <<'EOF'
<?php
$iters = $_ENV["ITERS"];
$start = microtime(true);
for ($i = 1; $i <= $iters; $i++){
$finfo = new finfo(FILEINFO_MIME);
$type = $finfo->file("/bin/sh");
unset($finfo);
}
$ttl = microtime(true) - $start;
echo "Took: $ttl\n";
?>
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment