Adding custom timers for monitoring
Use the Custom Timer application class to monitor the time taken to run a part of a script. For this purpose, you import the STMTimer module to your Python script. This module is available in the $PATROL_HOME/stm/bin directory.
Use the following syntax to start and end a custom timer:
timer.start('custom timer name')
For example, in the following code, we have added two custom timers: login and logout:
from selenium import webdriver
from STMTimer import STMTimer
driver = webdriver.Chrome()
timer = STMTimer()
timer.start('login')
"""Login steps"""
timer.stop('login')
timer.start('logout')
"""Logout steps"""
timer.stop('logout')driver.quit
Microsoft Edge browser:
timer = STMTimer()
timer.start('login')
"""Login steps"""
timer.stop('login') driver.quit
The custom timers names that you use in your script are shown on the PATROL Agent device page under the script execution plan instance: PATROL Agent device > Applications > Application name > Script execution plan name > Custom Timers > custom timer name.