Code Monkey home page Code Monkey logo

page-load-logger's Introduction

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

page-load-logger's People

Contributors

mattipv4 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.