<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amicalement Web - Astuces et Bons plans dans le développement web &#187; performance</title>
	<atom:link href="http://www.amicalement-web.net/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amicalement-web.net</link>
	<description>Astuces et bons plans d&#039;un web developpeur</description>
	<lastBuildDate>Wed, 04 Jan 2012 14:54:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Symfony Live 2010 : 2eme journée</title>
		<link>http://www.amicalement-web.net/symfony-live-2010-2eme-journee/2010/02/19/</link>
		<comments>http://www.amicalement-web.net/symfony-live-2010-2eme-journee/2010/02/19/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 10:00:15 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Actualité]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=1237</guid>
		<description><![CDATA[Après une première journée, un peu éprouvante &#8211; levé 5h30, couché 2h &#8211; on est reparti au front, avec dans la ligne de mire la preview de Symfony 2. Forcément, ca motive. Matinée Okapi Bon, on avoue, on a un peu zappé cette conférence, histoire de gagner un peu plus de temps de sommeil pour [...]]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.amicalement-web.net/symfony-live-2010-2eme-journee/2010/02/19"><img src="http://www.amicalement-web.net/wp-content/uploads/estrade.jpg" alt="" title="estrade" width="614" height="100" class="alignnone size-full wp-image-1312" /></a> Après <a  href="/symfony-live-2010-1ere-journee/2010/02/17/">une première journée</a>, un peu éprouvante &#8211; levé 5h30, couché 2h &#8211; on est reparti au front, avec dans la ligne de mire la preview de Symfony 2. Forcément, ca motive.<br />
<span id="more-1237"></span></p>
<h3>Matinée</h3>
<h4>Okapi</h4>
<p>Bon, on avoue, on a un peu zappé cette conférence, histoire de gagner un peu plus de temps de sommeil pour tenir sur la durée, et en profiter pour mettre au propre le billet d&#8217;hier. On a juste retenu qu&#8217;ils utilisaient le <a  href="http://components.symfony-project.org/dependency-injection/">Dependency Injection Container</a> des components symfony.</p>
<p>Mais vous pouvez <a  href="http://www.slideshare.net/lsmith77/okapi-meet-symfony-symfony-meet-okapi">retrouver les slides</a>.</p>
<h4>Optimisation PHP</h4>
<p>Un tour complet à coup d&#8217;exemple de opcode, intéressant même si au final ce sont toujours les mêmes choses qui sont redites, très génériques. Je me tends à croire qu&#8217;un jour on aura un vrai cas concret dans ce genre d&#8217;intervention.</p>
<p>Et puis surtout, quand on utilise un framework, on a plus à gagner, <strong>à bien utiliser le framework</strong> qu&#8217;à optimiser une boucle. </p>
<p>Mais on a réussi à avoir quelques tips supplémentaires pendant la séance de questions :</p>
<ul>
<li>La pré incrémentation est plus rapide que la post incrémentation</li>
<li>Toujours privilégier la boucle while à une boucle for</li>
<li>Bannir les relations parent/enfant &#8211; L&#8217;enfant pointe sur le parent et inversement. Pas bon pour la mémoire</li>
</ul>
<p><a  href="http://www.slideshare.net/xdecock/php-performance-sflive-2010">Voir les slides</a><br />
Et pour aller plus loin dans le sujet, une <a  href="http://www.slideshare.net/fabianlange/full-stack-web-application-performance-tuning-presentation">ancienne présentation de Fabian Lange</a>.</p>
<h4>Git introduction</h4>
<p>Une des premières sessions Show Time, où Scott Chacon y est allé franco pour présenter Git, à une assistance majoritairement SVN.<br />
Une petite autopromo : rapidité, travail offline (sauf pull et push) et <strong>puissance du système de branches</strong> ont suffit à mettre le doute dans la tête de beaucoup, à ce qu&#8217;on pouvait lire sur twitter après coup.</p>
<p>Il a ensuite donné le lien d&#8217;une librairie pour <a  href="http://redotheoffice.com/?p=130">contrôler git depuis PHP (glib)</a> et a su répondre à la principale question:</p>
<dl>
<dt>Un équivalent de SVN externals?</dt>
<dd>Bien sûr, git uses submodules, mais il faut les mettre à jour à la main (donc 2 commandes au lieu d&#8217;une pour mettre à jour, ça reste raisonnable)</dd>
</dl>
<p><a  href="http://www.slideshare.net/chacon/git-101-presentation">Voir les slides</a></p>
<h4>Zend Framework</h4>
<p>Est arrivé, celui qui s&#8217;est présenté comme &laquo;&nbsp;N&#8217;est pas l&#8217;ennemi&nbsp;&raquo;, le lead developer du Zend Framework.<br />
Il a rappelé combien étaient nombreuses les librairies et composants développés et combien <strong>il était facile de les inclure dans symfony</strong>. Ca m&#8217;a d&#8217;ailleurs fait penser, que je ne regarde sans doute pas assez chez eux, quand j&#8217;ai besoin d&#8217;une librairie externe.</p>
<p><a  href="http://www.slideshare.net/weierophinney/using-zend-framework-with-symfony">Voir les slides</a><br />
Et Matthew a ensuite fait un debriefing son intervention <a  href="http://weierophinney.net/matthew/archives/232-Symfony-Live-2010.html">sur son blog</a>.</p>
<h3>Aprem</h3>
<h4>Implementing Symfony CMS</h4>
<p>La première touche hispanique de la conférence, qui nous a rappelé combien <strong>symfony était vraiment international</strong>. Marcos, nous a donc expliqué pourquoi avoir choisi symfony pour développer les CMS de leur client et l&#8217;approche qu&#8217;ils ont eu pour le réaliser.</p>
<p>Pas de gros scoop, ni d&#8217;exemple super concret mais une approche intéressante et surtout, t<strong>irée d&#8217;une vrai expérience dans le domaine</strong>.</p>
<p><a  href="http://www.slideshare.net/esmiz/implementing-a-symfony-based-cms-in-a-publishing-company">Voir les slides</a></p>
<h4>Event System</h4>
<p>Deuxième intervention de Dennis sur un des mécanismes sans doute le moins utilisé dans la panoplie Symfony, les events. Après avoir repris, ce qu&#8217;on peut trouver sur Symfony-Project, il a démontré pourquoi <strong>le couplage trop fort, c&#8217;était le mal </strong>- et donc <strong>les events le bien</strong> (ou le mal aussi, voir ci-dessous).</p>
<p>Un petit sondage fait sur twitter, a montré combien les possibilités étaient larges. Mais aussi qu&#8217;on pouvait en faire tout et n&#8217;importe quoi &#8211; Merci <a  href="http://twitter.com/ubermuda">ubermuda</a> pour la démonstration :p.<br />
Ce qui nous a valu l&#8217;expression &laquo;&nbsp;Events, No silver bullet!&nbsp;&raquo; &#8211; Entendre par là, que ce n&#8217;est pas la solution à tout.</p>
<p>En résumé, <strong>un event s&#8217;utilise pour du &laquo;&nbsp;couplage optionnel&nbsp;&raquo;</strong>, sinon ça revient à avoir un couplage fort également.</p>
<p>Des questions assez peu pertinentes dans l&#8217;ensemble, comme quoi, c&#8217;était pas clair pour tout le monde les events, la conf était donc nécessaire contrairement à ce qu&#8217;on pouvait lire sur twitter.</p>
<p><a  href="http://www.slideshare.net/denderello/symfony-live-2010-using-symfony-events-to-create-clean-class-interfaces">Voir les slides</a></p>
<h4>Symfony in the cloud</h4>
<p>Kris, de la core team, avec cette présentation aura remporté le prix des meilleurs transitions et de <strong>la slide la plus Hollywoodienne</strong>, avec une démo en temps réel de la création d&#8217;un nuage &#8211; musique de circonstance pour l&#8217;occasion &#8211; où il a réussi un tour de force en rajoutant un nuage en arrière plan de son nuage!<br />
Le public était conquis.</p>
<p>Plus sérieusement, il a pris comme support son site nebul.us, pour montrer comment <strong>interconnecter Symfony avec différents environnement à base de nuage</strong>, 3 serveurs Mysql &#8211; 1 Master, 2 Slaves &#8211; n apache, S3 pour le stockage.</p>
<p>De très belles démo de code pour bénéficier <strong>des nouvelles possibilités d&#8217;extension de Doctrine 1.2</strong> &#8211; à voir dans les slides &#8211; entre autres mais aussi d&#8217;<strong>utilisation de composant Zend</strong>.</p>
<p>L&#8217;effet démo ne l&#8217;aura au final pas épargné lui aussi, une tentative de release en direct de son plugin pour gérer les couples Master/Slave et un beau fail quand il est revenu sur la page d&#8217;accueil après qu&#8217;il se soit reloggué suite à l&#8217;expiration de sa session sur symfony-project :D</p>
<p>À noter que cette présentation aurait pu ne pas avoir lieu si <a  href="http://twitter.com/vjousse">Vince</a> n&#8217;avait pas sauvé la mise, en sortant un adaptateur dvi ancienne génération pour le prêter à Kris :p</p>
<p><a  href="http://www.slideshare.net/kriswallsmith/symfony-in-the-cloud">Voir les slides</a></p>
<h4>Debug Symfony</h4>
<p>Une vrai démonstration de l&#8217;approche à avoir pour <strong>vraiment optimiser son application</strong>. Plutôt que de se demander si echo sera plus rapide avec une virgule ou un point.</p>
<p>Il encourage de<strong> logguer en base</strong>, pour y avoir accès plus facilement et ajouter des notions de filtrage aisément et insiste sur<strong> les avantages du profiling</strong>, même s&#8217;il a oublié qu&#8217;<a  href="http://www.symfony-project.org/plugins/elXHProfPlugin">un plugin Symfony était dispo</a> pour ça .</p>
<p>On a pu noter les outils utilisés pour le benchmark et les metrics, <a  href="http://tsung.erlang-projects.org/">Tsung</a> et Graphite, que je ne connaissais pas. Toujours ça de bon à prendre aussi !</p>
<p>Une présentation très complète mais rien d&#8217;inédit que vous trouverez <a  href="http://www.slideshare.net/old_sound/debugging-and-profiling-symfony-apps">dans les slides</a>.</p>
<h4>Yahoooo</h4>
<p>Comme d&#8217;habitude, Dustin, membre de la core team, et Yahoo man est venu présenter un peu le boulot de Yahoo autour de symfony. Pourquoi symfony, leurs contributions, leurs modifications.<br />
Un petit tour des sites actuels développés sur le framework, avec un slide où on a pu apercevoir Shopgenie \o/ &#8211; la version anglaise de MonsieurPrix, développée par moi même ;) ca fait toujours plaisir!</p>
<p>Il a ensuite abordé le développement d&#8217;application web plus généralement et les bonnes questions à se poser concernant les choix à faire dans le design d&#8217;une architecture. Avec en guise de conclusion, une transition toute trouvée : &laquo;&nbsp;<strong>Symfony 2 is the right direction</strong>&nbsp;&raquo; !</p>
<p>On notera au passage un petit sondage de l&#8217;assistance sur les framework js, que<strong> jQuery a remporté</strong> avec une écrasante majorité.</p>
<p><a  href="http://www.slideshare.net/dustin.whittle/building-a-platform-from-open-source-at-yahoo-3209565">Voir les slides</a></p>
<h4>Symfony 2 preview</h4>
<p>Est arrivée, la présentation que tout le monde attendait, Symfony 2 ! Il faudrait un billet dédié à lui même, et on va beaucoup en parler dans les prochaines semaines, donc je vais pas m&#8217;attarder longtemps.</p>
<p>On peut retenir, que <strong>Symfony 2 sera orienté configuration</strong> &#8211; tout est configurable &#8211; et <strong>couplage faible</strong> avec un passage sur PHP 5.3. Il ne sera plus question également de développer des choses annexes, comme le logger ou le système de cache, mais d&#8217;<strong>utiliser des librairies reconnues</strong> pour ça (dont celles du Zend Framework justement).</p>
<p>Il a bien insisté sur le fait, que Symfony 2 pourra faire exactement les mêmes choses que la version 1, mais <strong>plus simplement et surtout plus rapidement</strong>. Avec par exemple, le lazy load &#8211; on charge seulement ce dont le framework a besoin.</p>
<p>Avec une conclusion &laquo;&nbsp;Faster as hell! &laquo;&nbsp;.</p>
<p>Bon il n&#8217;aura pas échappé à l&#8217;effet démo, avec une tentative de commit de la preview release en direct, qui s&#8217;est soldée également par un échec. Le compte Wifi de la Cité Universitaire était expiré ;-) Mais vous pouvez désormais récupérer le code source de cette première version et faire joujou avec sur <a  href="http://www.symfony-reloaded.org">le site dédié à Symfony 2</a> !</p>
<p><a  href="http://www.slideshare.net/fabpot/symfony-20-revealed">Voir les slides</a></p>
<p>Il ne restait plus qu&#8217;à faire le chemin inverse, Direction Marseille. En espérant avoir l&#8217;occasion de revenir ;)</p>
<p class="alignright">
<em>Vos envoyés spéciaux pour l&#8217;évènement: Vince et Tim</em>
</p>
<p style="clear: both">
<small>Crédit photo: http://www.flickr.com/photos/xavierbriand/4368850785/in/set-72157623335239339/</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/symfony-live-2010-2eme-journee/2010/02/19/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Développement Web: les bons plans de la semaine #18</title>
		<link>http://www.amicalement-web.net/developpement-web-les-bons-plans-de-la-semaine-18/2009/10/12/</link>
		<comments>http://www.amicalement-web.net/developpement-web-les-bons-plans-de-la-semaine-18/2009/10/12/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 17:29:23 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Bons plans]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=852</guid>
		<description><![CDATA[Nouvelle semaine, mais surtout nouveau boulot! Mais de raisons de changer une formule qui marche. Donc voici la listes des bons plans de la semaine, avec un peu de retard comparé à d&#8217;habitude j&#8217;avoue. Par contre, une question, ça vous intéresserait une série de best-of (en plus) sur les liens qui ont semble-t-il le mieux [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/mailbox.png" alt="mailbox" title="mailbox" width="614" height="100" class="alignnone size-full wp-image-884" /> Nouvelle semaine, mais surtout nouveau boulot! Mais de raisons de changer une formule qui marche. Donc voici la listes des bons plans de la semaine, avec un peu de retard comparé à d&#8217;habitude j&#8217;avoue.</p>
<p>Par contre, une question, ça vous intéresserait une série de best-of (en plus) sur les liens qui ont semble-t-il le mieux marcher? (le plus de clic)<br />
<span id="more-852"></span><br />
Pour vous aider à réfléchir, voici de quoi cliquer:</p>
<ul>
<li><a  href="http://www.skorks.com/2009/10/how-to-speed-up-your-website-by-80-or-more/">Améliorer la performance de votre site</a><br />
Alors oui, ce genre de tuto, on en trouve plein. Mais celui-là est vraiment complet et de qualité. Il méritait bien un lien!
</li>
<li><a  href="http://blog.lucas-ts.com/programacao/php/symfony/playing-with-symfony-templating-part-1/">Exemple pour inclure son moteur de template favori dans Symfony</a><br />
Avec la sortie du <a  href="http://blog.lucas-ts.com/programacao/php/symfony/playing-with-symfony-templating-part-1">composent template de Symfony 2</a>, voici un exemple d&#8217;utilisation pour inclure son système de template préféré.</li>
<li><a  href="http://www.catswhocode.com/blog/10-wordpress-plugins-for-developers">10 plugins wordpress pour développeur</a><br />
Parce que wordpress c&#8217;est bien, mais des fois, en tant que dev, on aimerait plus.</li>
<li><a  href="http://docs.jquery.com/QUnit">Les tests unitaires en javascript</a><br />
Avec l&#8217;ampleur que prend le javascript depuis l&#8217;arrivée des framework jquery et consor, ca méritait bien un peu d&#8217;ordre de ce monde de brute</li>
<li><a  href="http://wiki.github.com/anthonyshort/csscaffold">Surcouche PHP pour gérer et optimiser ses CSS</a><br />
Sans doute le lien de la semaine. Un petit tour sur le screencast vous en dira beaucoup. Mais le principe de rajouter un petit framework PHP pour faciliter et optimiser vos CSS. A essayer et à adopter.</li>
<li><a  href="http://www.sohtanaka.com/web-design/greyscale-hover-effect-w-css-jquery/">L&#8217;effet grisé dégradé en jquery</a><br />
L&#8217;effet de la semaine. Un très bon rendu!</li>
</ul>
<p>Une liste un peu courte, mais la faute à une grosse semaine dernière! Je me rattraperais ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/developpement-web-les-bons-plans-de-la-semaine-18/2009/10/12/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Benchmark Apache: doctrine hydrate object vs array</title>
		<link>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/</link>
		<comments>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 09:00:59 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[hydrate]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.amicalement-web.net/?p=806</guid>
		<description><![CDATA[Il faut se rendre à l&#8217;évidence, défendre une idée sans argument, c&#8217;est bien souvent très compliqué. Et quand il a fallu que j&#8217;arrive à quantifier le réel apport d&#8217;une hydratation en tableau plutôt qu&#8217;en object, c&#8217;était un peu difficile. Rappelez-vous, j&#8217;en avais parlé dans les secrets de doctrine. Je me suis donc dis que j&#8217;allais [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.amicalement-web.net/wp-content/uploads/clock.png" alt="clock" title="clock" width="614" height="100" class="alignnone size-full wp-image-829" /> Il faut se rendre à l&#8217;évidence, défendre une idée sans argument, c&#8217;est bien souvent très compliqué. Et quand il a fallu que j&#8217;arrive à quantifier le réel apport d&#8217;une hydratation en tableau plutôt qu&#8217;en object, c&#8217;était un peu difficile. Rappelez-vous, j&#8217;en avais parlé <a  href="/doctrine-quelques-petits-secrets/2009/08/26/">dans les secrets de doctrine</a>.</p>
<p>Je me suis donc dis que j&#8217;allais tout simplement le benchmarker grosso modo, afin d&#8217;avoir une idée du gain qu&#8217;on peut avoir à passer par des tableaux. Car en fait, on sait très bien que le 2e est plus rapide, mais la question, c&#8217;est de combien.<br />
<span id="more-806"></span><br />
J&#8217;ai donc pris un modèle assez classique. Un couple de Departement/Region de France.</p>
<p>Dans mon fichier Table de mes départements, je rajoute la méthode suivante pour faire ma jointure sur régions</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createQuery</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span>
      <span style="color: #339933;">-&gt;</span><span style="color: #004000;">leftJoin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d.Regions r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Hydratation en objet</h3>
<p>Parfait, maintenant, je crée une action qui récupère seulement tous les items de ma table, soit environ <strong>100 départements</strong>, en relation avec une région chacun.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Departements'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ca reste un cas tout a fait commun. J&#8217;ai donc lancé un <code>ab</code>, un programme livré avec apache qui permet de lancer l&#8217;exécution d&#8217;une page web, n fois avec n requêtes concurrentielles.  j&#8217;ai décidé de le lancer <strong>100 fois avec 10 requêtes à la fois</strong>. Et voici le résultat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Document Path:          <span style="color: #000000; font-weight: bold;">/</span>hydrate<span style="color: #000000; font-weight: bold;">/</span>index
Document Length:        <span style="color: #000000;">2400</span> bytes
&nbsp;
Concurrency Level:      <span style="color: #000000;">10</span>
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests:  <span style="color: #000000;">16.862</span> seconds
Complete requests:      <span style="color: #000000;">100</span>
Failed requests:        <span style="color: #000000;">0</span>
Write errors:           <span style="color: #000000;">0</span>
Total transferred:      <span style="color: #000000;">269400</span> bytes
HTML transferred:       <span style="color: #000000;">240000</span> bytes
Requests per second:    <span style="color: #000000;">5.93</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;">#/sec] (mean)</span>
Time per request:       <span style="color: #000000;">1686.205</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Time per request:       <span style="color: #000000;">168.621</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Transfer rate:          <span style="color: #000000;">15.60</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes<span style="color: #000000; font-weight: bold;">/</span>sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received
&nbsp;
Connection Times <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
              min  mean<span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #000000; font-weight: bold;">/</span>-sd<span style="color: #7a0874; font-weight: bold;">&#93;</span> median   max
Connect:        <span style="color: #000000;">0</span>    <span style="color: #000000;">0</span>   <span style="color: #000000;">0.5</span>      <span style="color: #000000;">0</span>       <span style="color: #000000;">4</span>
Processing:  <span style="color: #000000;">1172</span> <span style="color: #000000;">1665</span> <span style="color: #000000;">167.3</span>   <span style="color: #000000;">1662</span>    <span style="color: #000000;">2337</span>
Waiting:     <span style="color: #000000;">1172</span> <span style="color: #000000;">1663</span> <span style="color: #000000;">166.5</span>   <span style="color: #000000;">1661</span>    <span style="color: #000000;">2337</span>
Total:       <span style="color: #000000;">1172</span> <span style="color: #000000;">1665</span> <span style="color: #000000;">167.4</span>   <span style="color: #000000;">1662</span>    <span style="color: #000000;">2338</span>
&nbsp;
Percentage of the requests served within a certain <span style="color: #000000; font-weight: bold;">time</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000;">50</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1662</span>
  <span style="color: #000000;">66</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1709</span>
  <span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1750</span>
  <span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1783</span>
  <span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1860</span>
  <span style="color: #000000;">95</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1928</span>
  <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2102</span>
  <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2338</span>
 <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">2338</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>longest request<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h3>Hydratation en tableau</h3>
<p>2e action, le même code, le même résultat HTML souhaité, mais on passe dans le execute le fameux paramètre. Notre résultat ne sera donc plus une Doctrine_Collection, mais un tableau associatif avec en clé, les noms des champs.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex2<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">items</span> <span style="color: #339933;">=</span> Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">getTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Departements'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>Doctrine<span style="color: #339933;">::</span><span style="color: #004000;">HYDRATE_ARRAY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et voici le résultat</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Document Path:          <span style="color: #000000; font-weight: bold;">/</span>hydrate<span style="color: #000000; font-weight: bold;">/</span>index2
Document Length:        <span style="color: #000000;">2400</span> bytes
&nbsp;
Concurrency Level:      <span style="color: #000000;">10</span>
Time taken <span style="color: #000000; font-weight: bold;">for</span> tests:   <span style="color: #000000;">10.086</span> seconds
Complete requests:      <span style="color: #000000;">100</span>
Failed requests:        <span style="color: #000000;">0</span>
Write errors:           <span style="color: #000000;">0</span>
Total transferred:      <span style="color: #000000;">269400</span> bytes
HTML transferred:       <span style="color: #000000;">240000</span> bytes
Requests per second:    <span style="color: #000000;">9.92</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #666666; font-style: italic;">#/sec] (mean)</span>
Time per request:       <span style="color: #000000;">1008.569</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Time per request:       <span style="color: #000000;">100.857</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>ms<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>mean, across all concurrent requests<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Transfer rate:          <span style="color: #000000;">26.09</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Kbytes<span style="color: #000000; font-weight: bold;">/</span>sec<span style="color: #7a0874; font-weight: bold;">&#93;</span> received
&nbsp;
Connection Times <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
              min  mean<span style="color: #7a0874; font-weight: bold;">&#91;</span>+<span style="color: #000000; font-weight: bold;">/</span>-sd<span style="color: #7a0874; font-weight: bold;">&#93;</span> median   max
Connect:        <span style="color: #000000;">0</span>    <span style="color: #000000;">1</span>   <span style="color: #000000;">1.4</span>      <span style="color: #000000;">0</span>       <span style="color: #000000;">6</span>
Processing:   <span style="color: #000000;">598</span>  <span style="color: #000000;">992</span> <span style="color: #000000;">112.9</span>   <span style="color: #000000;">1003</span>    <span style="color: #000000;">1239</span>
Waiting:      <span style="color: #000000;">598</span>  <span style="color: #000000;">991</span> <span style="color: #000000;">113.0</span>   <span style="color: #000000;">1002</span>    <span style="color: #000000;">1239</span>
Total:        <span style="color: #000000;">599</span>  <span style="color: #000000;">993</span> <span style="color: #000000;">113.0</span>   <span style="color: #000000;">1003</span>    <span style="color: #000000;">1239</span>
&nbsp;
Percentage of the requests served within a certain <span style="color: #000000; font-weight: bold;">time</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #000000;">50</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1003</span>
  <span style="color: #000000;">66</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1051</span>
  <span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1081</span>
  <span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1085</span>
  <span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1104</span>
  <span style="color: #000000;">95</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1128</span>
  <span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1149</span>
  <span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1239</span>
 <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span>   <span style="color: #000000;">1239</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>longest request<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h3>Bilan</h3>
<p>Alors évidemment, il faut prendre en compte la différence de temps de réponse qu&#8217;on peut avoir entre 2 lancement de <code>ab</code>. Mais l&#8217;objectif est surtout de montrer que le gain est non négligeable et vraiment réel.</p>
<p>On constate que le HTML reçu est bien le même. On a donc le même rendu!<br />
Et côté performance, le 1er cas nous donne une requête en <strong>1,7sec</strong> quand le 2e nous donne <strong>1s</strong> soit près de<strong> 60% de mieux</strong>.</p>
<p>Conclusion, quand on souhaite réaliser seulement de l&#8217;affichage de données, il faut hydrater en tableau! Même si dans le cas présent, on parle de 0,7sec, il faut voir que c&#8217;est un projet vierge avec rien d&#8217;autre autour. Le gain est donc bien réel et pas seulement gadget.</p>
<p><small>Crédit photo: http://www.flickr.com/photos/don3rdse/3208161023/</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amicalement-web.net/benchmark-apache-doctrine-hydrate-object-vs-array/2009/10/08/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
