How to time C++ functions for contributing?

Hi everyone,

I’m currently tackling my first issue in PyTorch by refactoring two functions. I noticed that there were two functions that appear to do the same thing but I’m guessing that time-wise they don’t operate the same. How would one run tests for benchmarking?

Here’s a relevant screenshot of what I wanna achieve:


Relevant commit

@thinking_tower
The performance test part to me is a self wrote script.
If you are under python. You can simply use timeit with string format to get the same output layout as above.

Hi @glaringlee!

Thanks for taking the time to answer my question!

I just want to check if this is valid:

  1. Time the original function.
  2. Make modifications to code.
  3. Rebuild (python setup.py develop --cmake along with some flags like BUILD_CAFFE2_OPS=0).
  4. Test (python run_test.py for the specific module) to ensure correctness.
  5. Time the function again (now that it’s been changed).

@thinking_tower
That make sense!.

1 Like