Created
November 17, 2016 22:17
-
-
Save spikeheap/79b0d0ffa3f49de20cf224b516c487d5 to your computer and use it in GitHub Desktop.
A naïve perftest of EmonCMS settings logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 10,000,000 | |
$run_count = 10000000; | |
$start_time = time(); | |
for ($i = 0; $i < $run_count; $i++) { | |
//1 #### Mysql database settings | |
if (isset($_ENV["MYSQL_HOST"])) $server = $_ENV["MYSQL_HOST"]; | |
if (isset($_ENV["MYSQL_DATABASE"])) $database = $_ENV["MYSQL_DATABASE"]; | |
if (isset($_ENV["MYSQL_USER"])) $username = $_ENV["MYSQL_USER"]; | |
if (isset($_ENV["MYSQL_PASSWORD"])) $password = $_ENV["MYSQL_PASSWORD"]; | |
if (isset($_ENV["MYSQL_PORT"])) $port = $_ENV["MYSQL_PORT"]; | |
//2 #### redis | |
// create the array if it's not already been done | |
if (!isset($redis_server)) $redis_server = array(); | |
if (isset($_ENV["REDIS_ENABLED"])) $redis_enabled = $_ENV["REDIS_ENABLED"] === 'true'; | |
if (isset($_ENV["REDIS_HOST"])) $redis_server['host'] = $_ENV["REDIS_HOST"]; | |
if (isset($_ENV["REDIS_PORT"])) $redis_server['port'] = $_ENV["REDIS_PORT"]; | |
if (isset($_ENV["REDIS_AUTH"])) $redis_server['auth'] = $_ENV["REDIS_AUTH"]; | |
if (isset($_ENV["REDIS_PREFIX"])) $redis_server['prefix'] = $_ENV["REDIS_PREFIX"]; | |
//3 #### MQTT | |
// create the array if it's not already been done | |
if (!isset($mqtt_server)) $mqtt_server = array(); | |
if (isset($_ENV["MQTT_ENABLED"])) $mqtt_enabled = $_ENV["MQTT_ENABLED"] === 'true'; | |
if (isset($_ENV["MQTT_HOST"])) $redis_server['host'] = $_ENV["MQTT_HOST"]; | |
if (isset($_ENV["MQTT_PORT"])) $redis_server['port'] = $_ENV["MQTT_PORT"]; | |
if (isset($_ENV["MQTT_USER"])) $redis_server['user'] = $_ENV["MQTT_USER"]; | |
if (isset($_ENV["MQTT_PASSWORD"])) $redis_server['password'] = $_ENV["MQTT_PASSWORD"]; | |
if (isset($_ENV["MQTT_BASETOPIC"])) $redis_server['basetopic'] = $_ENV["MQTT_BASETOPIC"]; | |
} | |
$end_time = time(); | |
echo 'Time taken for '.$run_count.' iterations: '.($end_time - $start_time).' seconds.'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment