cfa16cbe2f
* adding perfetto-validation-script * Rename validation script * Update tests/validate_perfetto.py Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com> * Update tests/validate_perfetto.py Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com> * Update tests/validate_perfetto.py Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com> * Update tests/validate_perfetto.py Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com> * addressed the edits in the validation script * addressed the edits in the validation script * Perfetto validation script (#1) * Fixed mismatch message in validate-timemory-json * validate_perfetto.py -> validate-perfetto-proto.py * Add python-source-validate-perfetto - python-source-validate-perfetto uses validate-python-proto.py to validate perfetto output - renamed python-source-check test to python-source-validate timemory * Moved python-source-validate tests outside of cat command if block - these tests don't rely on OMNITRACE_CAT_COMMAND * CMake/CTest OMNITRACE_ADD_PYTHON_VALIDATION_TEST function - generalized function for performing validation test with validate-{timemory-json,perfetto-proto}.py scripts * Print perfetto validation * Install perfetto python package in workflows * cmake format * Python formatting * Python formatting CI * Install perfetto python package in workflows * Install dataclasses for perfetto in opensuse * Install dataclasses for perfetto in ubuntu - uninstalled dependency for perfetto in Python 3.6 Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com> Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
48 line
1.1 KiB
Python
Executable File
48 line
1.1 KiB
Python
Executable File
#!@PYTHON_EXECUTABLE@
|
|
|
|
import os
|
|
import sys
|
|
import random
|
|
|
|
_prefix = ""
|
|
|
|
|
|
def fib(n):
|
|
return n if n < 2 else (fib(n - 1) + fib(n - 2))
|
|
|
|
|
|
def inefficient(n):
|
|
print(f"[{_prefix}] ... running inefficient({n})")
|
|
a = 0
|
|
for i in range(n):
|
|
a += i
|
|
for j in range(n):
|
|
a += j
|
|
_len = a * n * n * n
|
|
_arr = [random.random() for _ in range(_len)]
|
|
_sum = sum(_arr)
|
|
print(f"[{_prefix}] ... sum of {_len} random elements: {_sum}")
|
|
return _sum
|
|
|
|
|
|
def run(n):
|
|
_ret = 0
|
|
_ret += fib(n)
|
|
_ret += inefficient(n)
|
|
return _ret
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-n", "--num-iterations", help="Number", type=int, default=3)
|
|
parser.add_argument("-v", "--value", help="Starting value", type=int, default=20)
|
|
args = parser.parse_args()
|
|
|
|
_prefix = os.path.basename(__file__)
|
|
print(f"[{_prefix}] Executing {args.num_iterations} iterations...\n")
|
|
for i in range(args.num_iterations):
|
|
ans = run(args.value)
|
|
print(f"[{_prefix}] [{i}] result of run({args.value}) = {ans}\n")
|