takes torch.benchmark objects and compares delta of second vs first.
(first, first_descriptor, second, second_descriptor)
| 110 | # microseconds and milliseconds measurements: |
| 111 | |
| 112 | def get_perf(first, first_descriptor, second, second_descriptor): |
| 113 | """takes torch.benchmark objects and compares delta of second vs first.""" |
| 114 | faster = second.times[0] |
| 115 | slower = first.times[0] |
| 116 | gain = (slower-faster)/slower |
| 117 | if gain < 0: gain *=-1 |
| 118 | final_gain = gain*100 |
| 119 | print(f" Performance delta: {final_gain:.4f} percent improvement with {second_descriptor} ") |
| 120 | |
| 121 | ###################################################################### |
| 122 | # And then run the performance comparison: |