Topic: Extensions performance: xml vs. php files

Hello

I have many extensions in my plans. I need to transform all changes which I made from 1.2.x to 1.3.x. One important question to PunBB Developers:

What is better for code performance? put all code to manifest.xml or move as much as possible to external PHP files?

External PHP files are better while creating extension (you don't need to uninstall/install extension after every tiny change). But what is better for final release?

I noticed, that all extensions are cached in cache_hooks.php file. So this one file can be really big after adding many extensions. Will moving code to external files be better?

Thanks smile

(I hope that everybody understand my poor-grammar English wink )

YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: Extensions performance: xml vs. php files

Maybe punbb use xml to make user easy to use it (just install and uninstall)

3 (edited by YonasH 2008-12-28 17:14)

Re: Extensions performance: xml vs. php files

anggiawan wrote:

Maybe punbb use xml to make user easy to use it (just install and uninstall)

Yes - it's easy to install. In seccond solution it is still easy. You can add php files to your extensions directory, and include them using

require $ext_info['path'].'/your_file_path.php




I'll give more detailed example wink





Solution 1 all code in one file :
punbb/extensions/extension1/manifest.xml

<hook id="some_hook_id"><![CDATA[
php_code_line_1;
php_code_line_2;
php_code_line_3;
php_code_line_4;
php_code_line_5;
php_code_line_6;
php_code_line_7;
]]></hook>



OR Solution 2 code separated from manifest.xml :
punbb/extensions/extension1/manifest.xml

<hook id="some_hook_id"><![CDATA[
require $ext_info['path'].'/my_code.php
]]></hook>

punbb/extensions/extension1/my_code.php

<?php
php_code_line_1;
php_code_line_2;
php_code_line_3;
php_code_line_4;
php_code_line_5;
php_code_line_6;
php_code_line_7;
?>
YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: Extensions performance: xml vs. php files

If you want to time a hook:

<hook id="hook_name"><![CDATA[
$start = microtime(true);
//your code (try both ways)
$hook_time['hook_name'] = microtime(true) - $start;
]]></hook>

Then add this extra hook:

<hook id="ft_debug_end"><![CDATA[
if($hook_time)
foreach($hook_time as $k=>$v)
echo '<p><b>'.$k.':</b> '.rtrim(sprintf('%f', $v), '0').' seconds</p>';
]]></hook>

then compare the times, I guess.