Browse Source

tests/perf_bench: Add some viper performance benchmarks.

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
parent
commit
73fccf5967
  1. 19
      tests/perf_bench/viper_call0.py
  2. 19
      tests/perf_bench/viper_call1a.py
  3. 19
      tests/perf_bench/viper_call1b.py
  4. 19
      tests/perf_bench/viper_call1c.py
  5. 19
      tests/perf_bench/viper_call2a.py
  6. 19
      tests/perf_bench/viper_call2b.py

19
tests/perf_bench/viper_call0.py

@ -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)

19
tests/perf_bench/viper_call1a.py

@ -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)

19
tests/perf_bench/viper_call1b.py

@ -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)

19
tests/perf_bench/viper_call1c.py

@ -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)

19
tests/perf_bench/viper_call2a.py

@ -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)

19
tests/perf_bench/viper_call2b.py

@ -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…
Cancel
Save