@@ -491,7 +491,7 @@ def profile2df(
491491 ::
492492
493493 import pstats
494- from pyquickhelper.pycode .profiling import profile2df
494+ from onnx_array_api .profiling import profile2df
495495
496496 ps = pstats.Stats('bench_ortmodule_nn_gpu6.prof')
497497 df = profile2df(pd)
@@ -519,7 +519,7 @@ def profile(
519519 sort: str = "cumulative",
520520 rootrem: Optional[str] = None,
521521 as_df: bool = False,
522- return_results= False,
522+ return_results: bool = False,
523523 **kwargs,
524524) -> str:
525525 """
@@ -532,17 +532,22 @@ def profile(
532532 :param as_df: return the results as a dataframe and not text
533533 :param return_results: if True, return results as well
534534 (in the first position)
535- :param kwargs: additional parameters used to create the profiler
535+ :param kwargs: additional parameters used to create the profiler,
536+ see :epkg:`cProfile.Profile`
536537 :return: raw results, statistics text dump (or dataframe is *as_df* is True)
537538
538539 .. plot::
539540
540541 import matplotlib.pyplot as plt
541- from pyquickhelper.pycode.profiling import profile
542- from pyquickhelper.texthelper import compare_module_version
542+ from onnx_array_api.profiling import profile
543+
544+ def subf(x):
545+ return sum(x)
543546
544547 def fctm():
545- return compare_module_version('0.20.4', '0.22.dev0')
548+ x1 = subf([1, 2, 3])
549+ x2 = subf([1, 2, 3, 4])
550+ return x1 + x2
546551
547552 pr, df = profile(lambda: [fctm() for i in range(0, 1000)], as_df=True)
548553 ax = df[['namefct', 'cum_tall']].head(n=15).set_index(
@@ -585,8 +590,7 @@ def clean_text(res):
585590 res = res.replace(sub[0], sub[1])
586591 else:
587592 raise TypeError(
588- "rootrem must contains strings or tuple not {0}"
589- ".".format(rootrem)
593+ f"rootrem must contains strings or tuple not {rootrem!r}."
590594 )
591595 return res
592596
0 commit comments