Created
July 11, 2012 18:54
-
-
Save hans-d/3092353 to your computer and use it in GitHub Desktop.
benchmark setup
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
\\ bootstrap\connections | |
Connections::add('default', array( | |
'type' => 'database', | |
'adapter' => 'MySql', | |
'host' => 'localhost', | |
'login' => 'test', | |
'password' => 'test', | |
'database' => 'test', | |
'encoding' => 'UTF-8' | |
)); | |
Connections::add('doctrine', array( | |
'type' => 'Doctrine', | |
'driver' => 'pdo_mysql', | |
'host' => 'localhost', | |
'user' => 'test', | |
'password' => 'test', | |
'dbname' => 'test' | |
)); | |
\\ app\models\BenchmarkLi3 | |
class Benchmark extends \lithium\data\Model { | |
protected $_meta = array( | |
'source' => 'benchmarkdata', | |
'key' => array('date_key', 'string_id', 'field') | |
); | |
} | |
\\ app\models\BenchmarkDoctrine | |
use Doctrine\ORM\Mapping\Column; | |
use Doctrine\ORM\Mapping\Entity; | |
use Doctrine\ORM\Mapping\GeneratedValue; | |
use Doctrine\ORM\Mapping\Id; | |
use Doctrine\ORM\Mapping\Table; | |
/** | |
* @Entity | |
* @Table(name="benchmarkdata") | |
*/ | |
class BenchmarkDoctrine extends \li3_doctrine2\models\BaseEntity { | |
static $connectionName = 'doctrine'; | |
/** | |
* @Id | |
* @Column(type="string") | |
*/ | |
private $date_key; | |
public function getDateKey() { return $this->date_key; } | |
/** | |
* @Id | |
* @Column(type="string",length=16) | |
*/ | |
private $string_id; | |
public function getStringId() { | |
return $this->string_id; | |
} | |
/** | |
* @Id | |
* @Column(type="string",length=30) | |
*/ | |
private $field; | |
public function getField() { | |
return $this->field; | |
} | |
/** | |
* @Column(type="string",length=3) | |
*/ | |
private $field2; | |
public function getField2() { | |
return $this->field2; | |
} | |
/** | |
* @Column(type="string",length=30) | |
*/ | |
private $field3; | |
public function getField3() { | |
return $this->field3; | |
} | |
/** | |
* @Column(type="string") | |
*/ | |
private $date_string; | |
public function getDateString() { | |
return $this->date_string; | |
} | |
} | |
\\ app\controllers\BenchmarkController | |
use app\models\BenchmarkLi3; | |
use app\models\BenchmarkDoctrine; | |
class BenchmarkController extends \lithium\action\Controller { | |
public function li3() { | |
$test = Benchmark::all(); | |
$test = $test->to('array'); // will best show in profiler where time is spend | |
// have a view loop over the data (not really needed with a ->to('array') | |
} | |
public function doctrine() { | |
$dql = "SELECT b FROM app\models\BenchmarkDoctrine b"; | |
$em = BenchmarkDoctrine::getEntityManager(); | |
$query = $em->createQuery($dql); | |
$test = $query->getResult(); | |
// have a view loop over the data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jails - the li3 code for the benchmark