Jekyll2015-09-14T10:12:09+00:00http://unimapper.github.io/UniMapperFaster, harder, reflection!2014-08-25T00:00:00+00:002014-08-25T00:00:00+00:00http://unimapper.github.io/development/2014/08/25/fasther-harder-reflection<p>It’s been a long time I post something new, shame on me! :-) But there was a lot of things to do with this library and the next big thing is entity reflection refactoring.</p>
<h2 id="problem">Problem</h2>
<p>Stumbling block of entire library was demanding on system resources during the reflection load. I made some performance test with this benchmark and the result was something between ~ <code>20s / 70 MB</code> on my PC, which was terrible.</p>
<h2 id="after-refactoring">After refactoring</h2>
<p>But after a few cups of coffee and one sleepless saturday night, came the results in the form of ~ <code>5s / 19 MB</code>. Test focus on data <em>(~300000 rows)</em> stored in MySQL database, which are joined with 1:N and M:N relation, so I choosed our <a href="https://github.com/unimapper/dibi">Dibi extension</a>. After all, you can test it on your own from <a href="https://github.com/bauer01/db-benchmark/tree/unimapper">here</a>.</p>
<h2 id="what-i-actually-did">What I actually did?</h2>
<p>The problem was, that almost every attempt to find out some information about entity meant creating a new instance of reflection, so I made a lazy creation of related entity reflections. That means, every entity reflection brings an array with related entity reflections from its property definitions.</p>
<p><strong>Example:</strong></p>
<pre><code class="language-php">namespace Model;
/**
* @adapter MyAdapter(table_name)
*
* @property Child $entity
*/
class MyEntity extends \UniMapper\Entity
{}
$reflection = new UniMapper\Reflection\Entity("Model\MyEntity");
var_dump($reflection->getRelated());
// Prints following:
// array( "Model\Child" => ... /* Child entity reflection object */ )
</code></pre>
<p>Yep, there is a lot of todos with reflection, but for starters it is not bad.</p>
bauer01It’s been a long time I post something new, shame on me! :-) But there was a lot of things to do with this library and the next big thing is entity reflection refactoring.Project published on Github2014-03-15T00:00:00+00:002014-03-15T00:00:00+00:00http://unimapper.github.io/development/2014/03/15/project-published-on-github<p>The original purpose of this tool was personal use in private projects and applications. The aim was to facilitate the work of the acquisition of data and their subsequent processing. However, as time went on, it began to look as if it could find application in projects for someone else. And because we love opensource, we offer it for anyone to use for free.</p>
bauer01The original purpose of this tool was personal use in private projects and applications. The aim was to facilitate the work of the acquisition of data and their subsequent processing. However, as time went on, it began to look as if it could find application in projects for someone else. And because we love opensource, we offer it for anyone to use for free.