Skip to content
A single Python script to log page load speeds to an SQLite database
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
config.ini
requirements.txt
run.py

README.md

Page Load Logger

A single Python script to log page load speeds to an SQLite database

Style Patreon Slack


Getting Started

Python Environment

This script is written to work with Python 3.6 & 3.7. For Windows & macOS, you can download Python from the official website. Installing Python on Linux is more complicated, please see the Hitchhiker's Guide to Python for more information.

It makes use of the requests library which will need to be installed through pip. This can be done by running python -m pip install requests in command line/terminal. You may need to use python3 (or similar) instead of python in some installations.

Configuration File

With the Python environment setup, the configuration file needs to be edited to test your desired site or sites. Within the config.ini file you will find two "variables" that can be set. Example values for both of these are provided within the config.ini file, as well as comments explaining each variable's purpose.

The first, [Tester] sites, is a comma separated list of all the sites that the script should test the loading speed for.

Eg. sites = https://google.co.uk, https://bbc.co.uk

The second value, [Database] file, is the file name (and location/path) of the database file that the results will be saved to.

Eg. file = results.db

Running the Script

With the Python environment prepared and the configuration file edited, the script should be ready to run. To do this, simply run python run.py in your command line/terminal. As with the pip command, python may need to be substituted with python3 or similar to access your python installation.

Accessing the Results Data

Once you have run the script, the results will be saved to the database file that your defined in the configuration file. This file is a flat-file SQLite database. You can view the data contained through a tool such as the DB Browser for SQLite.

Database Structure

Within the database there is a single schema, named results. This houses all result logs from the testing script. Each entry contains the following values:

  • test_id - INT - Autoincrement-ing ID for each log entry (primary key)
  • datetime_utc - DATETIME - The timestamp when the result was logged, in UTC
  • target_url - TEXT - The target URL of this test
  • time_seconds - REAL - The time the test request took to complete, in seconds
  • status_code - INT - The response status code from the website tested
  • request_error - TEXT - The error raised by the request if applicable
  • internal_ip - TEXT - The internal IP address of the device that ran the test
  • external_ip - TEXT - The external IP address of the device/network that ran the test

Note: If an error occurs during the request, status_code will be set to -1, time_seconds set to 0 and the error caught will be logged in request_error.

Contributing

Contributions are always welcome to this project!
Take a look at any existing issues on this repository for starting places to help contribute towards, or simply create your own new contribution to the project.

Please make sure to follow the existing standards within the project such as code styles, naming conventions and commenting/documentation.

When you are ready, simply create a pull request for your contribution and I will review it whenever I can!

Donating

You can also help me and the project out by contributing through a donation on PayPal or by supporting me monthly on my Patreon page.

Patreon PayPal

Discussion, Support and Issues

Need support with this project, have found an issue or want to chat with others about contributing to the project?

Please check the project's issues page first for support & bugs!

Not found what you need here?

  • If you have an issue, please create a GitHub issue here to report the situation, include as much detail as you can!
  • or, You can join our Slack workspace to discuss any issue, to get support for the project or to chat with contributors and myself:
Slack
You can’t perform that action at this time.