Skip to content

Commit

Permalink
refact: restored advanced performance logging
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jan 21, 2025
1 parent 78a5890 commit 0f13aca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dyana/loaders/website/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"--wait-for-timeout", help="Timeout to wait for the CSS selectorin seconds", type=int, default=30
)
parser.add_argument("--screenshot", help="Save a screenshot of the page", action="store_true")
parser.add_argument("--performance-log", help="Enable performance logging", action="store_true")
args = parser.parse_args()

# Normalize URL by adding https:// if protocol is missing
Expand All @@ -35,6 +36,9 @@
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--window-size=1920,1080")

if args.performance_log:
chrome_options.set_capability("goog:loggingPrefs", {"performance": "ALL"})

service = Service(executable_path=shutil.which("chromedriver"))
service.start()

Expand All @@ -56,6 +60,9 @@

profiler.track_memory("after_load")

if args.performance_log:
profiler.track_extra("performance_log", driver.get_log("performance"))

if args.screenshot:
try:
driver.get_screenshot_as_file("/tmp/screenshot.png")
Expand Down
4 changes: 4 additions & 0 deletions dyana/loaders/website/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ args:
- name: wait-for-timeout
description: Timeout in seconds for page load and element wait.
required: false

- name: performance-log
description: Enable advanced performance logging.
required: false

0 comments on commit 0f13aca

Please sign in to comment.