Profilers
This topic describes how to use Profile
to record speed statistics.
Usage
You can save the statistical record to a txt, csv or json file.
from tensorbay.client import profile
# Start record.
with profile as pf:
# <Your Program>
# Save the statistical record to a file.
pf.save("summary.txt", file_type="txt")
Set multiprocess=True
to record the multiprocessing program.
# Start record.
profile.start(multiprocess=True)
# <Your Program>
# Save the statistical record to a file.
profile.save("summary.txt", file_type="txt")
profile.stop()
The above action would save a summary.txt file and the result is as follows:
|Path |totalTime (s) |callNumber |avgTime (s) |totalResponseLength |totalFileSize (B)|
|[GET] data06/labels |11.239 |25 |0.450 |453482 |0 |
|[GET] data06/data/urls |16.739 |25 |0.670 |794545 |0 |
|[POST] oss-cn-shanghai |0.567 |10 |0.057 |0 |8058707 |
Note
The profile will only record statistics of the interface that interacts with Tensorbay.