Test | Brython (100 = CPython) |
Code |
---|---|---|
simple assignment | 63 | for i in range(1000000): a = 1 |
augmented assignment | 50 | a = 0 for i in range(1000000): a += 1 |
augmented assignment and list append | 408 | t = [] i = 0 while i < 100000: t.append(i) i += 1 |
simple assignment to float | 99 | for i in range(1000000): a = 1.0 |
big integers | 249 | n = 60 for i in range(10000): 2 ** n |
hash string | 234 | for i in range(1000000): hash('abcdef') |
hash float | 179 | for i in range(1000000): hash(86.55) |
build dictionary | 385 | for i in range(1000000): a = {0: 0, 'a': 'a'} |
build dictionary 2 | 120 | d = {} for i in range(100000): d[i] = i |
set dictionary item | 240 | a = {0: 0} for i in range(1000000): a[0] = i |
build set | 1069 | for i in range(1000000): a = {0, 2.7, "x"} |
build list | 63 | for i in range(1000000): a = [1, 2, 3] |
set list item | 108 | a = [0] for i in range(1000000): a[0] = i |
list slice | 191 | a = [1, 2, 3] for i in range(100000): a[:] |
integer addition | 67 | a, b, c = 1, 2, 3 for i in range(1000000): a + b + c |
integer + float | 78 | a, b = 1, 2.0 for i in range(1000000): a + b |
float addition | 98 | a, b = 1.0, 2.0 for i in range(1000000): a + b |
string addition | 63 | a, b, c = 'a', 'b', 'c' for i in range(1000000): a + b + c |
cast int to string | 170 | for i in range(100000): str(i) |
create function without arguments | 189 | for i in range(1000000): def f(): pass |
create function, single positional argument | 191 | for i in range(1000000): def f(x): pass |
create function, complex arguments | 183 | for i in range(1000000): def f(x, y=1, *args, **kw): pass |
function call | 327 | def f(x): return x for i in range(1000000): f(i) |
function call, complex arguments | 313 | def f(x, y=0, *args, **kw): return x for i in range(100000): f(i, 5, 6, a=8) |
create simple class | 429 | for i in range(10000): class A: pass |
create class with init | 305 | for i in range(10000): class A: def __init__(self, x): self.x = x |
create instance of simple class | 851 | class A: pass for i in range(1000000): A() |
create instance of class with init | 703 | class A: def __init__(self): pass for i in range(100000): A() |
call instance method | 520 | class A: def f(self): pass a = A() for i in range(100000): a.f() |
set instance attribute | 429 | class A: pass a = A() for i in range(100000): a.x = i |