Skip to content

Commit c3e77ad

Browse files
AJMansfielddpgeorge
authored andcommitted
tests/internal_bench/class_create: Benchmark class creation.
Signed-off-by: Anson Mansfield <[email protected]>
1 parent d5dc554 commit c3e77ad

18 files changed

+253
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
pass
9+
10+
11+
bench.run(test)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import bench
2+
3+
4+
def test(num):
5+
l = ["x"]
6+
for i in range(num // 40):
7+
8+
class X:
9+
__slots__ = l
10+
11+
12+
bench.run(test)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import bench
2+
3+
4+
def test(num):
5+
l = ["a", "b", "c", "d", "x"]
6+
for i in range(num // 40):
7+
8+
class X:
9+
__slots__ = l
10+
11+
12+
bench.run(test)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
x = 1
9+
10+
11+
bench.run(test)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
a = 0
9+
b = 0
10+
c = 0
11+
d = 0
12+
x = 1
13+
14+
15+
bench.run(test)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import bench
2+
3+
4+
class Class:
5+
pass
6+
7+
8+
def test(num):
9+
instance = Class()
10+
for i in range(num // 40):
11+
12+
class X:
13+
a = instance
14+
b = instance
15+
c = instance
16+
d = instance
17+
x = instance
18+
19+
20+
bench.run(test)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
def x(self):
9+
pass
10+
11+
12+
bench.run(test)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
@classmethod
9+
def x(cls):
10+
pass
11+
12+
13+
bench.run(test)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
def __new__(cls):
9+
pass
10+
11+
12+
bench.run(test)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import bench
2+
3+
4+
def test(num):
5+
for i in range(num // 40):
6+
7+
class X:
8+
@staticmethod
9+
def x():
10+
pass
11+
12+
13+
bench.run(test)

0 commit comments

Comments
 (0)