I've just installed xdebug and kcachegrind to play around abit, get to know it and try to improve the world's best blogsoftware.
So I installed a fresh copy of serendipity1.0-beta2 on my laptop and started.
Here's the file: cachegrind.out.680592437 and a screenshot
First thing that came to my attention that serendipity_lang_en.inc.php uses 20,3% of the time spent. This can't possibly be and so I first thought of the multibyte stuff - nope. Then I realized that we have a 800 line file with define()s in it for every language. So I moved some of them away and voilá - no more language stuff near the top.
Then I made this script:<?php
function makeconst($num, $str) {
for ($i=0;$i<$num;$i++) {
define('SOMECONST',$str);
}
}
function makevar($num, $str) {
for ($i=0;$i<$num;$i++) {
$a = $str;
}
}
makeconst(1000, 'foobar');
makevar(1000, 'foobar');
?>
which produced following output: cachegrind.out.2897431826
Oh yes, variable assignment is 20x faster and so we could reduce 20% of time spent rendering a page to 1% by rewriting 90% of all files. Perhaps it would be better to store them in the database and just do a global search&replace with LANG_CHARSET becoming $foo['LANG_CHARSET'].
Stay tuned for more interesting profiling stuff, as I could scream for not having tried this before :P Linux on the desktop is at least good for anything but grief :)
Update:
graph with 7 entries on frontpage
screenshot with 7 entries
Update:
serendipity_event_emoticate.php sucks 1-2% performance, could be fixed by using strtr()
serendipity_makeFilename() uses 4% of total time, maybe there's room for improvement.
Other intensive stuff:
serendipity_plugin_api::hook_event - 19,85% - 24 calls
functions.inc.php - 5,92% - 1 call
Smarty->plugin_calendar.tpl.php - 6,97% - 1 call
Smarty->index.tpl.php - 3,93% - 1 call
language stuff - still 4% - 1 call
Smarty->_fetch_resource_info - 3,49% - 5 calls
Smarty->entries.tpl.php - 3,16% - 1 call
serendipity_event_s9ymarkup - 2,47% - 14 calls
serendipity_printEntries - 2,20% - 1 call
This was a bugfix release, including:
* 6050
* 6051
* 6732
* 5457
Nothing serious, just a few missing array keys, some E_STRICT/E_NOTICE issues and a bit of polishing the output.
It should still work fine under PEAR 1.3.3 and 1.4.0 - if you find any undiscovered bugs, please use the bugtracker as usual.
Because it was my first release I forgot to mention the bugs in package.xml.
I promise to do that next time.
When I started using MDB2, I found the possibilities quite overwhelming and so I decided to summarize everything you may need to start using it or want as a reference if you already use it and don't want to dig through the manuals for everything. Questions and hints on clarification are appreciated.
init a connection
$dsn = 'mysql://user:pass@host/db';
if (PEAR::isError($mdb2)) {
echo ($mdb2->getMessage());
}
querying
docs - query$result = $mdb2->query(string $query, [mixed $types = null]);
$result = $mdb2->queryAll(string $query, [array $types = null], [int $fetchmode = MDB2_FETCHMODE_DEFAULT], [boolean $rekey = false]);
//$rekey = if set to true, the $all will have the first column as its first dimension
$result = $mdb2->queryRow($string $query, [string $type = null]);
results
docs - setresultTypes$types = array('integer', 'text', 'timestamp');
$result->setResultTypes($types)
$result->fetchRow([int $fetchmode = MDB2_FETCHMODE_DEFAULT], [int $rownum = null]);
$result->fetchOne([int $colnum = 0]);
$result->fetchAll([int $fetchmode = MDB2_FETCHMODE_DEFAULT], [boolean $rekey = false]);
//$rekey = if set to true, the $all will have the first column as its first dimension
$result->fetchCol([int $colnum = 0]);
$result->getColumnNames();
$result->numCols();
$result->numRows();
$result->seek($int);
$result->nextResult();
$result->free();
fetch modes
MDB2_FETCHMODE_DEFAULT
MDB2_FETCHMODE_ORDERED
MDB2_FETCHMODE_ASSOC
MDB2_FETCHMODE_ORDERED | MDB2_FETCHMODE_FLIPPED
MDB2_FETCHMODE_ASSOC | MDB2_FETCHMODE_FLIPPED
MDB2_FETCHMODE_OBJECT
*/
security
misc
docs - lastInsertID$mdb2->lastInsertID();
$mdb2->nextID();
- the site has 0.5.5 as "development release", I tried installing it via PEAR
(instructions here - didn't work at all - then I tried svn-trunk, as was recommended. This worked better, but 2 more things happened:
- first pageload: template issue: "Notice: Undefined property: HTML_Template_Flexy_Token_Text"
- memory_limit of 16 MB may or may not be recommended by setup - I did get a Fatal error in PEAR::Date_Timezone when a "joined at" should've been displayed in a user page - they use trac, and I personally hate to register to file bugs - ok, no bug reports by me then :/
- minimalistic is ok, but when I see the default page introduced after a fresh install, why can't I edit it? - too strict separation of framework and cms? why is it installed then?
- when I login as admin, I am presented the modules page - when leaving it, however, I can't find my way back there without logging out and in again or remembering the url
Notice: Undefined property: HTML_Template_Flexy_Token_Text::$argTokens in seagull/lib/pear/HTML/Template/Flexy/Compiler/Standard.php on line 677
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 933888 bytes) in seagull/lib/pear/Date/TimeZone.php on line 3706
But here are the pros.
- documentation is very good - many projects could try that...
- the irc channel seems quite active, another good thing
- it looks good and I still would really like to dig in deeper
- dish out RCs and releases faster
- unit testing is fine, but how can it be that a new user can't get it too work? my dev webserver happily accepted the last ~20 opensource apps
- make submitting bugs open. don't force work on users. YOU want them to help your project
This is so unbelievably simple that I'm tempted to try to learn it by heart and in the future always reference this as his discovery. Hopefully he will promote his unique claim, as he isn't hesitating to tell the world, so that we all think of him when we say exactly what we have said tha last years...
Layout by Ricky Wilson | Serendipity Template by Carl Galloway | Login
About
Life's a bitch, life's a whore. Nothing less, nothing more.
Read More
Der Autor...
Quicksearch
last.fm
Song: World On Fire
Artist: Sarah McLachlan
Song: Grafton Street
Artist: Dido
Song: Warrior's Dance (Benga Remix)
Artist: The Prodigy


