Files
rocm-systems/projects/rocprofiler-systems/examples/python/external.py
T
Jonathan R. Madsen 6daac0f60c Python support (#37)
* Initial python support

* Add python testing

* Increase timeout for bin tests

* cmake-format

* Valid build types + testing + formatting + more

- Enforce valid build types
- Fix to numpy install
- Increase testing timeout
- Fix to cmake format glob
- Fix to backtrace verbose

* Disable stripping libraries by default

* omnitrace exe updates

- new '--print-instructions' option
- changed format of instructions in JSON
- remove no-save-fpr tests

* Default to strip libraries when release build

[ROCm/rocprofiler-systems commit: afa3edebab]
2022-04-05 00:24:34 -05:00

36 строки
644 B
Python
Исполняемый файл

#!@PYTHON_EXECUTABLE@
import sys
import numpy as np
def fib(n):
return n if n < 2 else (fib(n - 1) + fib(n - 2))
def inefficient(n):
print(f"inefficient: {n}")
a = 0
for i in range(n):
a += i
for j in range(n):
a += j
arr = np.random.rand(a * n * n * n)
sum = arr.sum()
print(f"sum: {sum}")
return sum
def run(nfib):
ret = 0
ret += fib(nfib)
ret += inefficient(nfib)
return ret
if __name__ == "__main__":
nfib = int(sys.argv[1]) if len(sys.argv) > 1 else 20
for i in range(5):
ans = run(nfib)
print(f"[{i}] fibonacci({nfib}) = {ans}")