[nycphp-talk] Profiling Applications

Joseph Crawford codebowl at
Tue Jan 11 14:42:26 EST 2005

Hello Everyone,

i have a database class that i have created to make working with the
database connections much easier for me, however on my dev machine i
have the following specs

P4 1.4ghz
128mb RDRAM

my question is this....

would my small amount of ram lag my mysql connections?
If i put the site on a live server with more ram etc.. would it load faster?
again this is on my dev machine, however i am thinking it is my
resources that are slowing it almost to a halt, i have never seen a
site (properly coded) that takes 5+ seconds to load the total load
time for this page and profile is
5.5078 seconds (according to my timer class).

i have profiled my app and i see that smarty and my DB::Open method
are what is hogging the load times.  for instance here is my open

	public function open() {
		$this->_link = mysql_connect( $this->_host, $this->_user, $this->_pass);
		if ( $this->_link == null ) {
			throw new MySQLEx( '$db->_link == null, connection to
'.$this->_host.' failed');
		if( !mysql_select_db( $this->_database, $this->_link ) ) {
			throw new MySQLEx("could not select database!<br>".mysql_error());

should that really take this long to run?
the rest of the page aside from these 2 objects run around 600 (ms)
each still slow but nowhere near as slow as these 2

here are the results of one such profiling


MySQL::__construct                               0.11 (ms)
MySQL::Open                                  4,199.46 (ms)
MySQL::FetchAll                                     0.22 (ms)
main                                                       0.92 (ms)
MySQL::NumRows                             163.25 (ms)
MySQL::Query                                    863.41 (ms)
MySQL::FetchArray                              12.11 (ms)

Total:                                              5.238.74 (ms)
Percent                                                46.90 percent


Smarty::Smarty                                   0.03 (ms)
Smarty::Display                                   0.03 (ms)
Smarty::fetch                                2,119.29 (ms)
main                                                 106.11 (ms)
Smarty::_get_plugin_filepath              1.74 (ms)
Smarty::_smarty_include             1,859.19 (ms)
Smarty::_is_compiled                        17.49 (ms)
Smarty::_get_compile_path                 0.26 (ms)
Smarty::_fetch_resource_info              1.47 (ms)
Smarty::_parse_resource_name      161.26 (ms)
Smarty::_get_auto_filename              20.46 (ms)
Smarty::assign                                      0.06 (ms)

Total:                                              4,297.84 (ms) 
Percent                                                38.40 percent

Joseph Crawford Jr.
Codebowl Solutions
codebowl at

More information about the talk mailing list