Hello I'm new and I want to port the PEAR HTML_Template_Sigma Class to an PHP extension.
I startet with the old book 'Building custom PHP Extensions' found now newer one. At the moment i have some class functions in my extension as they are in the PHP Class. So i try doing some bench :( Testing with php7. i call the class constructor from the extension 1000 times and also the same with the PHP class. $x = new HTML_Template_Sigma("dir","dir_cache"); PHP Class without opcache MEM: 2 mb, Time: 0.0366 sec PHP Class with opcache MEM: 2 mb, Time: 0.0269 sec Class from the extension MEM: 2 mb, Time: 0.0363 sec so the PHP Class with opcache ist faster as my extension. My goal was to write the class as an extension to get faster. so in the __construct from the PHP class are callback functions this one sets PHP or class methods as an class property in an array. $this->setCallbackFunction('h', array(&$this, '_htmlspecialchars')); $this->setCallbackFunction('e', array(&$this, '_htmlentities')); $this->setCallbackFunction('u', 'urlencode'); $this->setCallbackFunction('r', 'rawurlencode'); $this->setCallbackFunction('j', array(&$this, '_jsEscape')); when i set urlencode and rawurlencode in my extension like this it costs 0.01 sec zval tplFunction; ZVAL_STRING(&tplFunction,"u"); zval callback; ZVAL_STRING(&callback,"urlencode"); zend_call_method_with_2_params ( obj,Template_Sigma, NULL, "setcallbackfunction", NULL, &tplFunction, &callback); bench without the urlencode and rawurlencode call in the extension MEM: 2 mb, Time: 0.0262 end so I'm on the wrong way ? And if I'm on the write way how can i pass the object from a private method of the PHP extension class to the setcallback function as it is down in PHP with $this->setCallbackFunction('h', array(&$this, '_htmlspecialchars')); array(&$this, '_htmlentities') The next question should I use call_user_function or write this function in C. for example the private methode _jsEscape uses the PHP strtr and the second parameter is an array so the internal php_strtr_array function is called. Should I instead call the php_strtr function multiple times ? Best Regards Torsten -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php