Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/internal_bench/class_create-0-empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import bench


def test(num):
for i in range(num // 40):

class X:
pass


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-1-slots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
l = ["x"]
for i in range(num // 40):

class X:
__slots__ = l


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-1.1-slots5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
l = ["a", "b", "c", "d", "x"]
for i in range(num // 40):

class X:
__slots__ = l


bench.run(test)
11 changes: 11 additions & 0 deletions tests/internal_bench/class_create-2-classattr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import bench


def test(num):
for i in range(num // 40):

class X:
x = 1


bench.run(test)
15 changes: 15 additions & 0 deletions tests/internal_bench/class_create-2.1-classattr5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import bench


def test(num):
for i in range(num // 40):

class X:
a = 0
b = 0
c = 0
d = 0
x = 1


bench.run(test)
20 changes: 20 additions & 0 deletions tests/internal_bench/class_create-2.3-classattr5objs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import bench


class Class:
pass


def test(num):
instance = Class()
for i in range(num // 40):

class X:
a = instance
b = instance
c = instance
d = instance
x = instance


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-3-instancemethod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
for i in range(num // 40):

class X:
def x(self):
pass


bench.run(test)
13 changes: 13 additions & 0 deletions tests/internal_bench/class_create-4-classmethod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import bench


def test(num):
for i in range(num // 40):

class X:
@classmethod
def x(cls):
pass


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-4.1-classmethod_implicit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
for i in range(num // 40):

class X:
def __new__(cls):
pass


bench.run(test)
13 changes: 13 additions & 0 deletions tests/internal_bench/class_create-5-staticmethod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import bench


def test(num):
for i in range(num // 40):

class X:
@staticmethod
def x():
pass


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-6-getattribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
for i in range(num // 40):

class X:
def __getattribute__(self, name):
pass


bench.run(test)
12 changes: 12 additions & 0 deletions tests/internal_bench/class_create-6.1-getattr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bench


def test(num):
for i in range(num // 40):

class X:
def __getattr__(self, name):
pass


bench.run(test)
13 changes: 13 additions & 0 deletions tests/internal_bench/class_create-6.2-property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import bench


def test(num):
for i in range(num // 40):

class X:
@property
def x(self):
pass


bench.run(test)
17 changes: 17 additions & 0 deletions tests/internal_bench/class_create-6.3-descriptor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import bench


class D:
def __get__(self, instance, owner=None):
pass


def test(num):
descriptor = D()
for i in range(num // 40):

class X:
x = descriptor


bench.run(test)
14 changes: 14 additions & 0 deletions tests/internal_bench/class_create-7-inherit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import bench


def test(num):
class B:
pass

for i in range(num // 40):

class X(B):
pass


bench.run(test)
16 changes: 16 additions & 0 deletions tests/internal_bench/class_create-7.1-inherit_initsubclass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import bench


def test(num):
class B:
@classmethod
def __init_subclass__(cls):
pass

for i in range(num // 40):

class X(B):
pass


bench.run(test)
17 changes: 17 additions & 0 deletions tests/internal_bench/class_create-8-metaclass_setname.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import bench


class D:
def __set_name__(self, owner, name):
pass


def test(num):
descriptor = D()
for i in range(num // 40):

class X:
x = descriptor


bench.run(test)
21 changes: 21 additions & 0 deletions tests/internal_bench/class_create-8.1-metaclass_setname5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import bench


class D:
def __set_name__(self, owner, name):
pass


def test(num):
descriptor = D()
for i in range(num // 40):

class X:
a = descriptor
b = descriptor
c = descriptor
d = descriptor
x = descriptor


bench.run(test)
19 changes: 19 additions & 0 deletions tests/internal_bench/var-6.2-instance-speciallookup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import bench


class Foo:
def __init__(self):
self.num = 20000000

def __getattr__(self, name): # just trigger the 'special lookups' flag on the class
pass


def test(num):
o = Foo()
i = 0
while i < o.num:
i += 1


bench.run(test)
17 changes: 17 additions & 0 deletions tests/internal_bench/var-6.3-instance-property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import bench


class Foo:
@property
def num(self):
return 20000000


def test(num):
o = Foo()
i = 0
while i < o.num:
i += 1


bench.run(test)
20 changes: 20 additions & 0 deletions tests/internal_bench/var-6.4-instance-descriptor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import bench


class Descriptor:
def __get__(self, instance, owner=None):
return 20000000


class Foo:
num = Descriptor()


def test(num):
o = Foo()
i = 0
while i < o.num:
i += 1


bench.run(test)
16 changes: 16 additions & 0 deletions tests/internal_bench/var-6.5-instance-getattr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import bench


class Foo:
def __getattr__(self, name):
return 20000000


def test(num):
o = Foo()
i = 0
while i < o.num:
i += 1


bench.run(test)
Loading
Loading