3. Benchmarking and Profiling#
Introduction#
The benchmarking is essential to the progress and success of the project. Also, benchmarking code is a essential part of software development and it’s a software best practice. It can’t keep implementing new features without ensuring that what have been done. With benchmarking, we can confirm that our software does what it’s supposed to, and that it can handle most of the cases.
Memory Profiler#
Echoshader uses Time-based memory usage in Memory Profiler to execute benchmarking. This is a python module for monitoring memory consumption of a process as well as line-by-line analysis of memory consumption for python programs. It is a pure python module which depends on the psutil module.
Testing code, results and exporting HTMLs have been posted on Google Drive.
1 day with 1 min along ping_time, 1 m for depth (OOI 2017 Aug)
1 day with 10 min along ping_time, 5 m for depth (Hake Survey)
30 days with 30 mins along ping_time, 1 m for depth (OOI 2017 Aug)
10 days with 30 mins along ping_time, 5 m for depth (Hake Survey)
2 hr in raw resolution (with 1 sec along ping_time, 0.2 m for depth) (OOI 2017 Aug)
2 hr in raw resolution (with 2 secs along ping_time, 0.2 m for depth) (hake survey)
Admin Panel#
Also, we can take use of Admin Panel in Panel library.
The /admin
panel provides an overview of the current application and provides tools for debugging and profiling. It can be enabled by passing the --admin
argument to the panel serve
command.
For example, we build a new testing file called ‘your_file_name.py’ or ‘your_file_name.ipynb’ below:
import xarray as xr
from pathlib import Path
from echoshader import echogram
MVBS_ds = xr.open_mfdataset(
str('test_admin.nc'),
data_vars='minimal', coords='minimal',
combine='by_coords'
)
pn = echogram.panel
echogram = echogram.Echogram(MVBS_ds)
pn.Row(echogram.widgets, echogram.view_gram).servable()
Don’t forget to use .servable()
to specify which component you want to display in the browser.
Then we input below command in cmd Prompt
or Anaconda Prompt
to start up the server:
panel serve --admin --profiler=snakeviz your_file_name.py
Users should use the commandline --admin
and --profiler
options. Don’t forget to specify the profiler.
Once enabled the server, input below urls to open procedure page and admin page:
http://localhost:your_port_number/your_file_name
http://localhost:your_port_number/admin
The overview page provides some details about currently active sessions, running versions and resource usage (if psutil
is installed).
The launch profiler profiles the execution time of the initialization of a particular application. It can be enabled by setting a profiler using the commandline --profiler
option. Available profilers include:
pyinstrument
: A statistical profiler with nice visual outputsnakeviz
: SnakeViz is a browser based graphical viewer for the output of Python’s cProfile module and an alternative to using the standard library pstats module.
Once enabled the launch profiler will profile each application separately and provide the profiler output generated by the selected profiling engine.