Leonardo Soto avatar Leonardo Soto committed cfa06d2

More lookups micro-benchmarks. Also duplicated all lookups benchmarks for testing on new style classes too

Comments (0)

Files changed (3)

 
         for i in xrange(self.rounds):
             pass
+
+class HasAttributeSuccesful(Test):
+    version = 1.0
+    operations = 5 * 3
+    rounds = 100000
+
+    def test(self):
+        class c:
+            def __init__(self):
+                self.x = self.y = self.z = 1
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+    def calibrate(self):
+        class c:
+            def __init__(self):
+                self.x = self.y = self.z = 1
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass
+
+class HasAttributeFailed(Test):
+    version = 1.0
+    operations = 5 * 3
+    rounds = 100000
+
+    def test(self):
+        class c:
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+    def calibrate(self):
+        class c:
+            pass
+
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass

NewStyleLookups.py

+from pybench import Test
+
+class SpecialClassAttributeNS(Test):
+
+    versibon = 2.0
+    operations = 5*(12 + 12)
+    rounds = 100000
+
+    def test(self):
+
+        class c(object):
+            pass
+
+        for i in xrange(self.rounds):
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            c.__a = 2
+            c.__b = 3
+            c.__c = 4
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+            x = c.__a
+            x = c.__b
+            x = c.__c
+
+    def calibrate(self):
+
+        class c(object):
+            pass
+
+        for i in xrange(self.rounds):
+            pass
+
+class NormalClassAttributeNS(Test):
+
+    version = 2.0
+    operations = 5*(12 + 12)
+    rounds = 100000
+
+    def test(self):
+
+        class c(object):
+            pass
+
+        for i in xrange(self.rounds):
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+            c.a = 2
+            c.b = 3
+            c.c = 4
+
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+            x = c.a
+            x = c.b
+            x = c.c
+
+    def calibrate(self):
+
+        class c(object):
+            pass
+
+        for i in xrange(self.rounds):
+            pass
+
+class SpecialInstanceAttributeNS(Test):
+
+    version = 2.0
+    operations = 5*(12 + 12)
+    rounds = 100000
+
+    def test(self):
+
+        class c(object):
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+            o.__a__ = 2
+            o.__b__ = 3
+            o.__c__ = 4
+
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+            x = o.__a__
+            x = o.__b__
+            x = o.__c__
+
+    def calibrate(self):
+
+        class c(object):
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass
+
+class NormalInstanceAttributeNS(Test):
+
+    version = 2.0
+    operations = 5*(12 + 12)
+    rounds = 100000
+
+    def test(self):
+
+        class c(object):
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+            o.a = 2
+            o.b = 3
+            o.c = 4
+
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+            x = o.a
+            x = o.b
+            x = o.c
+
+    def calibrate(self):
+
+        class c(object):
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass
+
+class HasAttributeSuccesfulNS(Test):
+    version = 1.0
+    operations = 5 * 3
+    rounds = 100000
+
+    def test(self):
+        class c(object):
+            def __init__(self):
+                self.x = self.y = self.z = 1
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+    def calibrate(self):
+        class c(object):
+            def __init__(self):
+                self.x = self.y = self.z = 1
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass
+
+class HasAttributeFailedNS(Test):
+    version = 1.0
+    operations = 5 * 3
+    rounds = 100000
+
+    def test(self):
+        class c(object):
+            pass
+        o = c()
+
+        for i in xrange(self.rounds):
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+            hasattr(o, 'x')
+            hasattr(o, 'y')
+            hasattr(o, 'z')
+
+    def calibrate(self):
+        class c(object):
+            pass
+
+        o = c()
+
+        for i in xrange(self.rounds):
+            pass
 from Calls import *
 from Constructs import *
 from Lookups import *
+from NewStyleLookups import *
 from Instances import *
 try:
     from NewInstances import *
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.