NVIDIA / NVTX

The NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications.
Apache License 2.0
312 stars 48 forks source link

Add no-op methods of public functions #24

Closed shwina closed 3 years ago

shwina commented 3 years ago

Adds no-op methods of public APIs like annotate, which are used if the env var NVTX_DISABLE is defined.

Depends on #23

Closes #12

Without NVTX_DISABLE:

In [1]: from nvtx import annotate

In [2]: @annotate()
   ...: def  foo():
   ...:     pass
   ...:

In [3]: %timeit foo()
328 ns ± 0.411 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

With NVTX_DISABLE:

In [1]: from nvtx import annotate

In [2]: @annotate()
   ...: def  foo():
   ...:     pass
   ...:

In [3]: %timeit foo()
49.4 ns ± 0.0631 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)