[Webkit-unassigned] [Bug 64262] Small speed up, which switches some virtual functions to inline ones.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jul 25 00:36:25 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=64262





--- Comment #17 from Czene Tamas <Czene.Tamas at stud.u-szeged.hu>  2011-07-25 00:36:24 PST ---
This patch, i used gprof values. example:  WebCore::CSSStyleApplyProperty::applyValue(CSSStyleSelector* selector, CSSValue* value) const  cumulative seconds 158.50 self seconds 0.26 

If we remove virtual function we will makes small speed up.
example:
Virtual function:

#include <climits>
using namespace std;

class BaseClass {
public:
  int k;
  BaseClass() { 
     k = 6; 
  }
  virtual int myFunction(int i)
  {
    return k+i;        
  }
};

int main()
{
 BaseClass p;
 int a;
for(int j=0;j<300;j++)
 for(int i=0; i<INT_MAX;i++)
    a+=i+p.myFunction(i);
 return a;
}


czene at czene-CELSIUS-W ~/Asztal $ g++ -O3 virtual.cpp -o virtual
czene at czene-CELSIUS-W ~/Asztal $ time ./virtual 

real        6m6.756s
user        2m30.241s
sys        3m17.356s

Inline:

#include <climits>
using namespace std;

class BaseClass {
public:
  int k;
  BaseClass() { 
     k = 6; 
  }
  inline int myFunction(int i)
  {
    return k+i;        
  }
};

int main()
{
 BaseClass p;
 int a;
for(int j=0;j<300;j++)
 for(int i=0; i<INT_MAX;i++)
    a+=i+p.myFunction(i);
 return a;
}

czene at czene-CELSIUS-W ~/Asztal $ g++ -O3 inline.cpp -o inline
czene at czene-CELSIUS-W ~/Asztal $ time ./inline 

real        6m1.851s
user        2m29.433s
sys        3m17.628s


The msn.com value not valid, i copied wrong text in the comment.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list