From 9b86b1d45bf68fb0a0f092eb0eee0ff153a45495 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 23 Aug 2014 20:14:04 +0200 Subject: [PATCH] Added --enable-profiler parameter to use with @krakjoe profiler --- src/pocketmine/PocketMine.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 5c3a9c27f..109bbc61a 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -149,7 +149,7 @@ namespace pocketmine { ini_set("memory_limit", "256M"); //Default define("pocketmine\\START_TIME", microtime(true)); - $opts = getopt("", array("enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard")); + $opts = getopt("", array("enable-ansi", "disable-ansi", "data:", "plugins:", "no-wizard", "enable-profiler")); define("pocketmine\\DATA", isset($opts["data"]) ? realpath($opts["data"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? realpath($opts["plugins"]) . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); @@ -158,6 +158,15 @@ namespace pocketmine { $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); + if(isset($opts["enable-profiler"])){ + if(function_exists("profiler_enable")){ + \profiler_enable(); + $logger->notice("Execution is being profiled"); + }else{ + $logger->notice("No profiler found. Please install https://github.com/krakjoe/profiler"); + } + } + function kill($pid){ switch(Utils::getOS()){ case "win":