setup() public static method

Shortcut for initializing the static pheasant instance
public static setup ( $dsn = null ) : Pheasant
return Pheasant
コード例 #1
0
ファイル: MysqlTestCase.php プロジェクト: lox/pheasant
 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();
 }
コード例 #2
0
ファイル: common.php プロジェクト: lox/pheasant
<?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);
    }