Commit a368726f authored by Jonathan.Wage's avatar Jonathan.Wage

Removed/not used/outdated.

parent e08f9113
<?php
function mixin($tpl, $method = null)
{
static $_map;
if ( ! isset($_map[$tpl . $method])) {
if ($method === null) {
$refl = new ReflectionFunction($tpl);
} else {
$refl = new ReflectionMethod($tpl, $method);
}
$lines = file($refl->getFileName());
$start = $refl->getStartLine();
$end = $refl->getEndLine();
$ret = array_slice($lines, $start, ($end - $start));
$code = trim(trim(implode(' ', $ret)), '{}');
$_map[$tpl . $method] = $code;
} else {
$code = $_map[$tpl . $method];
}
eval($code);
}
function someCode() {
$a = 10;
}
class Template
{
public function exec()
{
$a = 10;
}
}
print "<pre>MIXIN BENCHMARK \n";
$timepoint = microtime(true);
$i = 500;
while ($i--) {
mixin('someCode');
}
print 'EXECUTED 500 CODE BLOCKS : ' . (microtime(true) - $timepoint) . "\n";
$timepoint = microtime(true);
$i = 500;
while ($i--) {
someCode();
}
print 'EXECUTED 500 DIRECT FUNCTION CALLS : ' . (microtime(true) - $timepoint) . "\n";
$timepoint = microtime(true);
$i = 500;
while ($i--) {
eval('$a = 10;');
}
print 'EXECUTED 500 DIRECT EVAL CALLS : ' . (microtime(true) - $timepoint) . "\n";
<?php
require_once '../lib/Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
class Entity extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', 20, 'autoincrement|primary');
$this->hasColumn('name', 'string', 50);
}
}
$dbh = new Doctrine_Db('sqlite:test.db');
$conn = Doctrine_Manager::getInstance()->openConnection($dbh);
// initialize some entities
$coll = new Doctrine_Collection('Entity');
$i = 10;
while ($i--) {
$coll[$i]->name = 'e ' . $i;
}
$coll->save();
$conn->clear();
print "<pre>DQL BENCHMARK \n";
$timepoint = microtime(true);
$i = 100;
$query = new Doctrine_Query();
$query->setOption('resultSetCache', new Doctrine_Cache_Array());
while ($i--) {
$query->from('Entity e')->where('e.id > 0');
$coll = $query->execute(array(), Doctrine::FETCH_ARRAY);
}
print 'EXECUTED 100 QUERIES WITH CACHING ENABLED + FETCH_ARRAY : ' . (microtime(true) - $timepoint) . "\n";
$timepoint = microtime(true);
$i = 100;
while ($i--) {
$query = new Doctrine_Query();
$query->from('Entity e')->where('e.id > 0');
$coll = $query->execute(array(), Doctrine::FETCH_ARRAY);
}
print 'EXECUTED 100 QUERIES WITHOUT CACHING + FETCH_ARRAY : ' . (microtime(true) - $timepoint) . "\n";
$timepoint = microtime(true);
$i = 100;
$query = new Doctrine_Query();
$query->setOption('resultSetCache', new Doctrine_Cache_Array());
while ($i--) {
$query->from('Entity e')->where('e.id > 0');
$coll = $query->execute();
}
print 'EXECUTED 100 QUERIES WITH CACHING ENABLED + FETCH_RECORD : ' . (microtime(true) - $timepoint) . "\n";
$timepoint = microtime(true);
$i = 100;
while ($i--) {
$query = new Doctrine_Query();
$query->from('Entity e')->where('e.id > 0');
$coll = $query->execute();
}
print 'EXECUTED 100 QUERIES WITHOUT CACHING + FETCH_RECORD : ' . (microtime(true) - $timepoint) . "\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment