BARTULA CODE

Checking page performance of websites

So today i was working with python to use the it to check load time of website.

Prerequirments

wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
tar -xf geckodriver-v0.26.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/
sudo yum install firefox

Script

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

def time_url(driver, url):
    driver.get(url)

    # Use the browser Navigation Timing API to get some numbers:
    # https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API
    navigation_start = driver.execute_script(
        "return window.performance.timing.navigationStart")
    dom_complete = driver.execute_script(
        "return window.performance.timing.domComplete")
    total_time = dom_complete - navigation_start

    print(f"Time {total_time}ms")

options = Options()
options.headless = True
driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver',options=options)

try:
    url = "https://httpbin.org/delay/"
    time_url(driver, url + '1')
    time_url(driver, url + '2')

finally:
    driver.close()

Result

python3.6 benchmark.py

Time 1677ms
Time 2258ms

Read more

Windows Use UTC Time

ctrl+R -> RegEdit -> enter Registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation Key: RealTimeIsUniversal Type: DWORD (32-bit) Value. Value: 1 Then restart PC

Extend »
HTTP 204 - No Content