wrk -t4 -c400 -d10s http://127.0.0.1:1337/
Running 10s test @ http://127.0.0.1:1337/
4 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 7.02ms 6.94ms 82.86ms 85.27%
This post is also on my blog, since Gist doesn't support @ notifications.
Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:
Ember.Controller
instead of Ember.ArrayController
or Ember.ObjectController
Ember.Controller
, otherwise a proxy will be generated. You can use Ember.RSVP.hash to simulate setting normal props on your controller.<?php | |
class AcmeController implements ContainerAwareInterface | |
{ | |
use ContainerAwareTrait; | |
use RedirectTrait; | |
public function indexAction() | |
{ | |
return $this->redirect('some_route', [ |
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
PHP 5.4: | |
======== | |
$ php54 bench1.php | |
0.36937880516052 | |
292432712 | |
$ php54 bench2.php | |
0.47057294845581 | |
193929016 |
<html> | |
<body> | |
<p>Here are Webber’s points:</p> | |
<ul> | |
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4.</li> | |
<li>echo is faster than print.(<em>* compare with list from phplens by John Lim</em>)</li> | |
<li>Use echo’s multiple parameters instead of string concatenation.</li> | |
<li>Set the maxvalue for your for-loops before and not in the loop.</li> | |
<li>Unset your variables to free memory, especially large arrays.</li> | |
<li>Avoid magic like __get, __set, __autoload</li> |
<?php // bundles/api_v1/controllers/example.php | |
class Api_V1_Example_Controller extends Controller | |
{ | |
public $restful = True; | |
public function get_hello($name='World') | |
{ | |
return "Hello, {$name}!"; | |
} |
<?php | |
/** | |
* @package Joomla.Plugin | |
* @subpackage System.Overrides | |
* | |
* @copyright Copyright (C) 2012 Don Gilbert. All rights reserved. | |
* @license GNU General Public License version 2 or later; see LICENSE | |
*/ | |
define('OVERRIDES', dirname(__FILE__).'/overrides'); |