Skip to content

worker package

Federico Dossena edited this page Sep 12, 2019 · 1 revision
SpeedtestWorker class

Performs the speedtest using a given TestPoint, SpeedtestConfig and TelemetryConfig. This is the Java equivalent of speedtest_worker.js. Creates a Thread. Starts immediately (no need to call start()).

Constructor:

public SpeedtestWorker(TestPoint backend, SpeedtestConfig config, TelemetryConfig telemetryConfig)
  • backend: the TestPoint to use to perform the speedtest
  • config: speedtest settings. Use null to use the default settings
  • telemetryConfig: telemetry settings. Use null to use the default settings (telemetry disabled)

The GetIP class is used to fetch IP and ISP info.

The download test uses multiple instances of DownloadStream to perform the test. After an initial grace time in which speed data is discarded, speed is measured as the amount of downloaded data over the amount of time it took to download it.

The upload test uses multiple instances of UploadStream to perform the test. After an initial grace time in which speed data is discarded, speed is measured as the amount of uploaded data over the amount of time it took to send it.

The ping test is performed by a single PingStream. The ping reported by the test is the lowest ping measured. Jitter is also calculated as the variance between consecutive pings.

At the end of the test, the Telemetry class is used to send telemetry (if enabled).

Each test can only be ran once.

Callbacks:

  • onDownloadUpdate is called periodically during the download test to report the download speed. dl is the current speed in Mbps, progress is a number between 0 and 1 representing how close we are to the time limit
  • onUploadUpdate is called periodically during the upload test to report the upload speed. ul is the current speed in Mbps, progress is a number between 0 and 1 representing how close we are to the time limit
  • onPingJitterUpdate is called periodically during the ping+jitter test to report ping and jitter times. ping is the current ping, jitter is the current jitter, progress is a number between 0 and 1 representing how close we are to the time limit
  • onIPInfoUpdate is called when the IP address and ISP information is received. ipInfo is a string combining this information
  • onTestIDReceived is called at the end of the test when we receive an ID from the telemetry. id is a string containing the test ID that can be used to generate a share link
  • onEnd is called at the end of the test
  • onCriticalFailure is called if the test fails. err is a string containing details about the error

Methods:

  • abort(): aborts the test as soon as possible. Use join() to wait for the test to die.
Clone this wiki locally