php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38630 OOP is still 3x slower than proc code.
Submitted: 2006-08-28 16:06 UTC Modified: 2006-08-28 17:55 UTC
From: dobes at lnx dot cz Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.1.5 OS: winXP
Private report: No CVE-ID: None
 [2006-08-28 16:06 UTC] dobes at lnx dot cz
Description:
------------
I checked small benchmark described on http://destiney.com/benchmarks/db_insert_select (wrote when PHP5.0.3 was current) and I get quite similar result ;-( But I checked PHP5.1.6 (this is not in your PHP version list).

I think bad perbormance of OOP code is bug and not feature.

Reproduce code:
---------------
look on http://destiney.com/benchmarks/db_insert_select, it's longer than 20 lines.

Expected result:
----------------
Just shorter run-time of OOP code.

Actual result:
--------------
Runtime of OOP scriot is still 3x longer than proc code (the same as in PHP5.0.3).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-28 16:24 UTC] tony2001@php.net
You are benchmarking totally different things.

<?php 
function foo() {
  bar();
}
foo();
?>

is always slower than

<?php
bar();
?>

in this universe.
 [2006-08-28 17:46 UTC] dobes at lnx dot cz
Yes, I agree, it have to be slower, but why 3 times? I change calling
$this->x = $this->g();
to direct calling 
$this->x = mt_rand( $this->l, $this->h );
and it improve runtime from
0m6.060s to 0m4.538s ... it is too big difference when I change only one calling of protected class function to the PHP internal.

I wrote this bug because I beleve in better performace of classes in next PHP versions.
 [2006-08-28 17:55 UTC] tony2001@php.net
>Yes, I agree, it have to be slower, but why 3 times?
Because you are calling 3 times more functions in your code.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC