public function setUp() { $dsn = getenv('PHEASANT_TEST_DSN') ?: 'mysql://root@localhost/pheasanttest?charset=utf8'; // initialize a new pheasant $this->pheasant = \Pheasant::setup($dsn); // wipe sequence pool $this->pheasant->connection()->sequencePool()->initialize()->clear(); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Pheasant\Types; $memory_peak = 0; declare (ticks=35); register_tick_function('log_peak_memory'); Pheasant::setup('mysql://root@localhost:/pheasanttest'); /** * Log peak memory usage */ function log_peak_memory() { global $memory_peak; if (($usage = memory_get_usage()) > $memory_peak) { $memory_peak = $usage; } } /** * Generic benchmarking function */ function benchmark($times, $callback) { global $memory_peak; $counts = array(); $memory = array(); $params = array_slice(func_get_args(), 2); // warm-up the benchmark for ($i = 0; $i < 5; $i++) { call_user_func_array($callback, $params); }