Browse Source
To test raw viper function call overhead: function entry, exit and conversion of arguments to/from objects.pull/4858/head
Damien George
5 years ago
6 changed files with 114 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f0(): |
|||
pass |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f0 |
|||
for _ in r: |
|||
f() |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f1a(x): |
|||
return x |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f1a |
|||
for _ in r: |
|||
f(1) |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f1b(x) -> int: |
|||
return int(x) |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f1b |
|||
for _ in r: |
|||
f(1) |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f1c(x:int) -> int: |
|||
return x |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f1c |
|||
for _ in r: |
|||
f(1) |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f2a(x, y): |
|||
return x |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f2a |
|||
for _ in r: |
|||
f(1, 2) |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
@ -0,0 +1,19 @@ |
|||
@micropython.viper |
|||
def f2b(x:int, y:int) -> int: |
|||
return x + y |
|||
|
|||
@micropython.native |
|||
def call(r): |
|||
f = f2b |
|||
for _ in r: |
|||
f(1, 2) |
|||
|
|||
bm_params = { |
|||
(50, 10): (15000,), |
|||
(100, 10): (30000,), |
|||
(1000, 10): (300000,), |
|||
(5000, 10): (1500000,), |
|||
} |
|||
|
|||
def bm_setup(params): |
|||
return lambda: call(range(params[0])), lambda: (params[0] // 1000, None) |
Loading…
Reference in new issue