tests/internal_bench/class_create: Benchmark class creation.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
This commit is contained in:
parent
d5dc554742
commit
c3e77ad6db
18 changed files with 253 additions and 0 deletions
11
tests/internal_bench/class_create-0-empty.py
Normal file
11
tests/internal_bench/class_create-0-empty.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import bench
|
||||
|
||||
|
||||
def test(num):
|
||||
for i in range(num // 40):
|
||||
|
||||
class X:
|
||||
pass
|
||||
|
||||
|
||||
bench.run(test)
|
||||
12
tests/internal_bench/class_create-1-slots.py
Normal file
12
tests/internal_bench/class_create-1-slots.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-1.1-slots5.py
Normal file
12
tests/internal_bench/class_create-1.1-slots5.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-2-classattr.py
Normal file
11
tests/internal_bench/class_create-2-classattr.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import bench
|
||||
|
||||
|
||||
def test(num):
|
||||
for i in range(num // 40):
|
||||
|
||||
class X:
|
||||
x = 1
|
||||
|
||||
|
||||
bench.run(test)
|
||||
15
tests/internal_bench/class_create-2.1-classattr5.py
Normal file
15
tests/internal_bench/class_create-2.1-classattr5.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-2.3-classattr5objs.py
Normal file
20
tests/internal_bench/class_create-2.3-classattr5objs.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-3-instancemethod.py
Normal file
12
tests/internal_bench/class_create-3-instancemethod.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-4-classmethod.py
Normal file
13
tests/internal_bench/class_create-4-classmethod.py
Normal file
|
|
@ -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)
|
||||
|
|
@ -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
tests/internal_bench/class_create-5-staticmethod.py
Normal file
13
tests/internal_bench/class_create-5-staticmethod.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-6-getattribute.py
Normal file
12
tests/internal_bench/class_create-6-getattribute.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-6.1-getattr.py
Normal file
12
tests/internal_bench/class_create-6.1-getattr.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-6.2-property.py
Normal file
13
tests/internal_bench/class_create-6.2-property.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-6.3-descriptor.py
Normal file
17
tests/internal_bench/class_create-6.3-descriptor.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-7-inherit.py
Normal file
14
tests/internal_bench/class_create-7-inherit.py
Normal file
|
|
@ -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)
|
||||
|
|
@ -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
tests/internal_bench/class_create-8-metaclass_setname.py
Normal file
17
tests/internal_bench/class_create-8-metaclass_setname.py
Normal file
|
|
@ -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
tests/internal_bench/class_create-8.1-metaclass_setname5.py
Normal file
21
tests/internal_bench/class_create-8.1-metaclass_setname5.py
Normal file
|
|
@ -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)
|
||||
Loading…
Reference in a new issue