On December 12, 2001 07:33 am, Andrei Zmievski wrote: > On Wed, 12 Dec 2001, Sterling Hughes wrote: > > And those functions would be? :) Are you talking about > > regularly used functions such as strlen(), etc.? > > Functions like count(), for example, that people tend to use in a > loop unnecessarily. > > > I agree that zend_basic_functions.c should remain abstracted, I > > guess where we draw the line is a bit fuzzy to me? What are > > your thoughts as to what functions should remain > > un-zend-parse-parameterized (say *that* 10 times fast :). > > Yes, the distinction is not clear. Perhaps, the person who does the > conversion for each module could do some benchmark tests on their > programs and see what might need to be adjusted.
I did a simple test with krsort before and after zend_parse_parameters. See the attached files for information on the changes that I made and the test that I used. In this case, it looks like we face at most about a 0.0001 second penalty per function call for using zend_parse_parameters. This is based on the data below: (4.762 seconds - 3.704 seconds) / 10000 calls to krsort) Profiling would probably be a better choice, however, I am having a few troubles getting profiling going with the PHP source. :) As always, correction and comments welcome. --- With zend_parse_parameters(): real 0m4.762s user 0m4.710s sys 0m0.030s real 0m4.738s user 0m4.700s sys 0m0.030s real 0m4.726s user 0m4.700s sys 0m0.020s Without zend_parse_parameters(): real 0m3.704s user 0m3.620s sys 0m0.040s real 0m3.833s user 0m3.660s sys 0m0.020s real 0m3.764s user 0m3.650s sys 0m0.010s -- Zak Greant PHP Quality Assurance Team http://qa.php.net/ "We must be the change we wish to see." - M. K. Ghandi
<?php foreach (file ('/usr/local/src/data.txt') as $k => $v) { $array[$v] = $k; } define (MAX, 10000); for ($x=0; $x < MAX; ++$x) { $data = $array; krsort ($data); } ?>
Index: ext/standard/array.c =================================================================== RCS file: /repository/php4/ext/standard/array.c,v retrieving revision 1.148 diff -u -r1.148 array.c --- ext/standard/array.c 11 Dec 2001 15:30:27 -0000 1.148 +++ ext/standard/array.c 13 Dec 2001 07:19:29 -0000 @@ -179,39 +179,34 @@ return array_key_compare(a, b TSRMLS_CC) * -1; } -/* {{{ proto int krsort(array array_arg [, int sort_flags]) - Sort an array reverse by key */ +/* {{{ proto bool krsort(array array_arg [, int sort_flags]) + Sort an array by key value in reverse order */ PHP_FUNCTION(krsort) { - zval **array, **sort_type; - int sort_type_val = SORT_REGULAR; + zval *array; + long sort_type_val = SORT_REGULAR; HashTable *target_hash; - if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 || - zend_get_parameters_ex(ZEND_NUM_ARGS(), &array, &sort_type) == FAILURE) { - WRONG_PARAM_COUNT; - } - target_hash = HASH_OF(*array); - if (!target_hash) { - php_error(E_WARNING, "Wrong datatype in krsort() call"); - return; - } - if (ZEND_NUM_ARGS() == 2) { - convert_to_long_ex(sort_type); - sort_type_val = Z_LVAL_PP(sort_type); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type_val) == FAILURE) { + RETURN_FALSE; } + + target_hash = HASH_OF(array); set_compare_func(sort_type_val TSRMLS_CC); + if (zend_hash_sort(target_hash, zend_qsort, array_reverse_key_compare, 0 TSRMLS_CC) == FAILURE) { - return; + RETURN_FALSE; } + RETURN_TRUE; } /* }}} */
CODING_STANDARDS CREDITS CVS ChangeLog ChangeLog.1999.gz ChangeLog.2000.gz EXTENSIONS INSTALL LICENSE Makefile Makefile.in NEWS README.CVS-RULES README.EXTENSIONS README.EXT_SKEL README.PARAMETER_PARSING_API README.QNX README.SELF-CONTAINED-EXTENSIONS README.STREAMS README.Zeus RELEASE_PROCESS TODO TODO-4.2.txt TSRM Zend acconfig.h acconfig.h.in acinclude.m4 aclocal.m4 apidoc-zend.txt apidoc.txt build buildconf buildmk.stamp config.guess config.log config.nice config.status config.sub config_vars.mk configure configure.in cvsclean dynlib.m4 ext footer generated_lists genfiles header install-sh libphp4.la libs libtool ltmain.sh main makedist makerpm missing mkinstalldirs modules pear php.ini-dist php.ini-recommended php4.gif php4.spec php4.spec.in php_version.h regex run-tests.php sapi scripts snapshot stamp-h.in stub.c stub.lo stub.o tests win32
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]