Giter VIP home page Giter VIP logo

speedtest's Introduction

Presentation

SpeedTest is a simple script used to estimate your average connection speed in KiloBytes per second. No Flash, just HTML5.

Works with the latest versions of Firefox, Chrome and Safari.

Installation

Add the speedtest.js file to your web page :

<script src="./speedtest.js"></script>

And finish by adding the speedtest.php file on your server.

Public interface

Here is a simple presentation of the SpeedTest interface.

Constructor

SpeedTest( settings, startNow )

settings must contain an object with the properties or events you want to modify, example :

var settings = {

  download: {
    onprogress: function() { //... }
  },

  maxTime: 10000

}

startNow is used to launch immediatly a double request (download AND upload).

Event handlers

Function download.onprogress ( Number currentSpeed, Number minSpeed, Number maxSpeed )
Function download.onload ( Number averageSpeed, Number minSpeed, Number maxSpeed )

Function upload.onprogress ( Number currentSpeed, Number minSpeed, Number maxSpeed )
Function upload.onload ( Number averageSpeed, Number minSpeed, Number maxSpeed )

Example of use :

var STInstance = new SpeedTest();

STInstance.download.onprogress = function(speed, min, max) {
  console.log('Current speed : '+ speed);
  console.log('Minimum speed : '+ min);
  console.log('Maximum speed : '+ min);
};

minSpeed and maxSpeed are measured a short delay after the request has started. Don't be surprised if you see a value like 0 when the request is starting.

Properties

Boolean requesting
Number maxTime
String serverFile

requesting indicates if the SpeedTest instance is actually running a request. THIS IS READ-ONLY!

maxTime is the maximum time you want to see a request running (a request is just a download or an upload, not the two of them). Zero means there is no limit, the request will stop until all the data has been received/sent.

serverFile is just the HTTP address for the speedtest.php file.

Methods

Void startRequest( download, twoRequests )

download : true for download, false for upload.

twoRequests allows you to run two requests with a single use of startRequest(). If download is set at true, it will start with the downloading test and will continue with the uploading test. If downloadis at false, it will do the opposite, upload first and download after.

speedtest's People

Contributors

charley-peng avatar nesk avatar

Watchers

 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.