- Add new tests for phalcon:
- Use Cache for load posts from DB in 'posts' most heavy page.
- Add posibility for viewing testing result of releseas
- results for 0.0.5
- results of testing release 0.0.6
More informations about changes.
About cache and eager loading in laravel, I wrote in my previews post.
Now we add caching functional on page 'posts' in phalcon framework.
Let`s add new Controller:
PostwsController() in phalcon-3.2/app/controllers/PostswcController.php
use Phalcon\Cache\Backend\File as BackFile;
use Phalcon\Cache\Frontend\Data as FrontData;
/**
* Index action
*/
public function indexAction()
{
$posts = null;
$frontCache = new FrontData(
[
'lifetime' => 172800,
]
);
$cache = new BackFile(
$frontCache,
[
'cacheDir' => '../app/cache/',
]
);
$cacheKey = 'posts.cache';
$posts = $cache->get($cacheKey);
if ($posts === null) {
$this->persistent->parameters = null;
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = [];
}
//$parameters["limit"] = "100";
//$parameters["limit"] = array('number' => 100, 'offset' => 10);
$parameters["order"] = "id";
$posts = Posts::find($parameters);
$cache->save($cacheKey, $posts);
}
if (count($posts) == 0) {
$this->flash->notice("The search did not find any posts");
$this->dispatcher->forward([
"controller" => "postsCache",
"action" => "index"
]);
return;
}
//var_dump($posts);
$this->view->posts = $posts;
}
Views we can copy from posts to postswc:
phalcon-3.2/app/views/layouts/posts.phtml -> phalcon-3.2/app/views/layouts/postswc.phtml
folder phalcon-3.2/app/views/posts -> folder phalcon-3.2/app/views/postswc
And that`s all. New page 'postswc' we can see by link
After tests we see that adding a cache did not change the situation. In table !!phalcon-postswc
row.
framework | requests per second | relative | peak memory | relative |
---|---|---|---|---|
phalcon-index | 113.17 | 2,829.3 | 0.49 | 1.0 |
phalcon-authors | 22.35 | 558.8 | 0.61 | 1.3 |
phalcon-categories | 13.61 | 340.3 | 0.62 | 1.3 |
laravel-index | 8.67 | 216.8 | 6.21 | 12.7 |
laravel-posts-el-cache | 8.00 | 200.0 | 7.34 | 15.1 |
laravel-posts-el | 7.79 | 194.8 | 7.34 | 15.1 |
laravel-categories | 6.97 | 174.3 | 7.59 | 15.6 |
laravel-authors | 6.90 | 172.5 | 7.34 | 15.1 |
!! phalcon-postswc | 0.10 | 2.5 | 2.45 | 5.0 |
phalcon-posts | 0.09 | 2.3 | 2.36 | 4.8 |
laravel-posts | 0.04 | 1.0 | 15.13 | 31.0 |
laravel-posts-cache | 0.04 | 1.0 | 18.46 | 37.9 |
I'll tell you about adding eager loading
next time, because there is not eager loading
in Phalcon from the box
.
In this release I have change the sctructure for releases result viewing.
For every next release it's testing results will be commited in repository (bm/result-releases/0.0.5/output
, bm/result-releases/0.0.6/output
, bm/result-releases/...../output
, etc.)
And they can be viewed on http://php-frameworks.semasping.info/bm/result-releases/0.0.6/index.php where 0.0.6
- release version.
That links will be added to release informations on github
This release: https://github.com/semasping/php_frameworks_for_tests/releases/tag/0.0.6
Commits in this release:
- results for 0.0.5
- new structure for releases result viewing
- add cache tests for phalcon (for release 0.0.6)
- result of testing release 0.0.6
Roadmap:
Try to use Cache for all frameworks(Done for laravel. Done for Phalcon)- Find Eager Loading functional for Phalcon 3.2 (or try
stibiumz/phalcon.eager-loading
for Phalcon 1.3.* - 2.0.*.) - Implementing a test application and running tests on Symfony
- Implementing a test application and running tests on Yii
- Connection with https://blackfire.io/
- Deal with the Docker and wrap it all up in it. To be able to quickly deploy to a more powerful server for comparison.
PS: More information about structure of test application
- Part 1. Introduction. - Why i decide to do new bencmark of php frameworks.
- Part 2. Database scheme and generating data for testing app. - Description of application, database structure and data.
- Part 3. Phalcon
- Part 4. Laravel
- Part 5. Cache and Eager Loading for Laravel framework
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
Very detailed
Please add a license to your repo.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you!
Done
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ни фига не поняла, но я За! За качественные вклады в мир open-source:-)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @semasping I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit