From 0f13aca8751054dd1c86ff5c210d58c99a44e7a6 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Tue, 21 Jan 2025 21:54:23 +0100 Subject: [PATCH] refact: restored advanced performance logging --- dyana/loaders/website/main.py | 7 +++++++ dyana/loaders/website/settings.yml | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/dyana/loaders/website/main.py b/dyana/loaders/website/main.py index c0a325b..d6f1dda 100644 --- a/dyana/loaders/website/main.py +++ b/dyana/loaders/website/main.py @@ -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 @@ -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() @@ -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") diff --git a/dyana/loaders/website/settings.yml b/dyana/loaders/website/settings.yml index acc137c..6d3eff9 100644 --- a/dyana/loaders/website/settings.yml +++ b/dyana/loaders/website/settings.yml @@ -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