{"id":19156859,"url":"https://github.com/bertrandmartel/speed-test-lib","last_synced_at":"2026-01-11T16:58:56.113Z","repository":{"id":41557086,"uuid":"41402757","full_name":"bertrandmartel/speed-test-lib","owner":"bertrandmartel","description":":cloud: JSpeedTest : speed test client library for Java/Android","archived":false,"fork":false,"pushed_at":"2023-04-13T09:45:42.000Z","size":777,"stargazers_count":385,"open_issues_count":25,"forks_count":119,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-03-28T10:09:56.818Z","etag":null,"topics":["android-library","java-library","speedtest"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bertrandmartel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-26T03:42:11.000Z","updated_at":"2025-03-02T08:41:26.000Z","dependencies_parsed_at":"2024-11-09T08:37:04.899Z","dependency_job_id":"bf3322a3-d925-4b84-b204-7feec40d16f8","html_url":"https://github.com/bertrandmartel/speed-test-lib","commit_stats":null,"previous_names":["akinaru/speed-test-lib"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Fspeed-test-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Fspeed-test-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Fspeed-test-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Fspeed-test-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bertrandmartel","download_url":"https://codeload.github.com/bertrandmartel/speed-test-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166169,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-library","java-library","speedtest"],"created_at":"2024-11-09T08:36:09.370Z","updated_at":"2026-01-11T16:58:56.100Z","avatar_url":"https://github.com/bertrandmartel.png","language":"Java","readme":"# JSpeedTest\n\n[![Build Status](https://travis-ci.org/bertrandmartel/speed-test-lib.svg?branch=master)](https://travis-ci.org/bertrandmartel/speed-test-lib)\n[![Download](https://api.bintray.com/packages/bertrandmartel/maven/speedtest/images/download.svg) ](https://bintray.com/bertrandmartel/maven/speedtest/_latestVersion)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/fr.bmartel/jspeedtest/badge.svg)](https://maven-badges.herokuapp.com/maven-central/fr.bmartel/jspeedtest)\n[![Coverage Status](https://coveralls.io/repos/github/bertrandmartel/speed-test-lib/badge.svg?branch=master)](https://coveralls.io/github/bertrandmartel/speed-test-lib?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/55e8e347e0d24566b37fe43799665e40)](https://www.codacy.com/app/bertrandmartel/speed-test-lib?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=bertrandmartel/speed-test-lib\u0026amp;utm_campaign=Badge_Grade)\n[![Javadoc](http://javadoc-badge.appspot.com/fr.bmartel/jspeedtest.svg?label=javadoc)](http://javadoc-badge.appspot.com/fr.bmartel/jspeedtest)\n[![License](http://img.shields.io/:license-mit-blue.svg)](LICENSE.md)\n\nSpeed Test client library for Java/Android with HTTP \u0026 FTP support\n\n* speed test download\n* speed test upload\n* download / upload progress monitoring\n* configurable hostname / port / uri (username \u0026 password for FTP)\n* configurable socket timeout and chunk size\n* configure upload file storage\n\nCheck a [non-exhaustive list](./server_list.md) of compatible speed test server.\n\n## Include in your project\n\n* with Gradle, from jcenter or mavenCentral :\n\n```gradle\ncompile 'fr.bmartel:jspeedtest:1.32.1'\n```\n\n## Usage\n\n* setup a speed test listener to monitor progress, completion and error catch :\n\n```java\nSpeedTestSocket speedTestSocket = new SpeedTestSocket();\n\n// add a listener to wait for speedtest completion and progress\nspeedTestSocket.addSpeedTestListener(new ISpeedTestListener() {\n\n    @Override\n    public void onCompletion(SpeedTestReport report) {\n        // called when download/upload is complete\n        System.out.println(\"[COMPLETED] rate in octet/s : \" + report.getTransferRateOctet());\n        System.out.println(\"[COMPLETED] rate in bit/s   : \" + report.getTransferRateBit());\n    }\n\n    @Override\n    public void onError(SpeedTestError speedTestError, String errorMessage) {\n         // called when a download/upload error occur\n    }\n\n    @Override\n    public void onProgress(float percent, SpeedTestReport report) {\n        // called to notify download/upload progress\n        System.out.println(\"[PROGRESS] progress : \" + percent + \"%\");\n        System.out.println(\"[PROGRESS] rate in octet/s : \" + report.getTransferRateOctet());\n        System.out.println(\"[PROGRESS] rate in bit/s   : \" + report.getTransferRateBit());\n    }\n});\n```\n\n### Download\n\n* HTTP download 1Mo from `http://ipv4.ikoula.testdebit.info`\n\n```java\nspeedTestSocket.startDownload(\"http://ipv4.ikoula.testdebit.info/1M.iso\");\n```\n\n* FTP download 1Mo from `speedtest.tele2.net`\n\n```java\nspeedTestSocket.startDownload(\"ftp://speedtest.tele2.net/1MB.zip\");\n```\n\n* FTP download 1Mo from `ftp.otenet.gr` with credentials (username/password), default is anonymous/no password\n\n```java\nspeedTestSocket.startDownload(\"ftp://speedtest:speedtest@ftp.otenet.gr/test1Mb.db\");\n```\n\n### Upload\n\n* HTTP upload 1Mo to `http://ipv4.ikoula.testdebit.info`\n\n```java\nspeedTestSocket.startUpload(\"http://ipv4.ikoula.testdebit.info/\", 1000000);\n```\n\n* FTP upload a 1Mo file to `speedtest.tele2.net`\n\n```java\nString fileName = SpeedTestUtils.generateFileName() + \".txt\";\nspeedTestSocket.startUpload(\"ftp://speedtest.tele2.net/upload/\" + fileName, 1000000);\n```\n\n### Fixed duration download\n\nDownload during a fixed duration. Download will be stopped when the max duration is reached.\n\n* HTTP download for 10s max, a 100 Mo file from `http://ipv4.ikoula.testdebit.info`\n\n```java\nspeedTestSocket.startFixedDownload(\"http://ipv4.ikoula.testdebit.info/100M.iso\", 10000);\n```\n\n* FTP download for 10s max, a 100 Mo file from `speedtest.tele2.net`\n\n```java\nspeedTestSocket.startFixedDownload(\"ftp://speedtest.tele2.net/100MB.zip\");\n```\n\n### Fixed duration Upload\n\nUpload during a fixed duration. Upload will be stopped when the max duration is reached\n\n* HTTP upload for 10s max, a 10Mo file to `http://ipv4.ikoula.testdebit.info`\n\n```java\nspeedTestSocket.startFixedUpload(\"http://ipv4.ikoula.testdebit.info/\", 10000000, 10000);\n```\n\n* FTP upload for 10s max, a 10Mo file to `speedtest.tele2.net`\n\n```java\nString fileName = SpeedTestUtils.generateFileName() + \".txt\";\nspeedTestSocket.startFixedUpload(\"ftp://speedtest.tele2.net/upload/\" + fileName, 10000000, 10000);\n```\n\n### Define report interval\n\nYou can define your own report interval (interval between each `onDownloadProgress` \u0026 `onUploadProgress`) in milliseconds.\n\n* HTTP download with download reports each 1.5 seconds\n\n```java\nspeedTestSocket.startDownload(\"http://ipv4.ikoula.testdebit.info/1M.iso\", 1500);\n```\n\n* FTP download with download reports each 1.5 seconds\n\n```java\nspeedTestSocket.startDownload(\"ftp://speedtest.tele2.net/1MB.zip\", 1500);\n```\n\n* HTTP upload with upload reports each 1.5 seconds\n\n```java\nspeedTestSocket.startUpload(\"http://ipv4.ikoula.testdebit.info/\", 10000000, 1500);\n```\n\n* FTP upload with upload reports each 1.5 seconds\n\n```java\nString fileName = SpeedTestUtils.generateFileName() + \".txt\";\nspeedTestSocket.startUpload(\"ftp://speedtest.tele2.net/upload/\" + fileName, 10000000, 1500);\n```\n\n### Use proxy server\n\n```java\nspeedTestSocket.setProxyServer(\"http://216.56.48.118:9000\");\n```\n\ndefault proxy server port is 8080\n\n### Chain download/upload requests\n\nYou can chain multiple download/upload requests during a fixed duration. This way, there will be as much download/upload request until the end of the period\n\n* download repeat\n\nThe following will download regularly for 20 seconds a file of 1Mo with download report each 2 seconds. Download reports will appear in `onReport` callback of `IRepeatListener` instead of `onDownloadProgress` :\n\n```java\nspeedTestSocket.startDownloadRepeat(\"http://ipv4.ikoula.testdebit.info/1M.iso\",\n    20000, 2000, new\n            IRepeatListener() {\n                @Override\n                public void onCompletion(final SpeedTestReport report) {\n                    // called when repeat task is finished\n                }\n\n                @Override\n                public void onReport(final SpeedTestReport report) {\n                    // called when a download report is dispatched\n                }\n            });\n```\n\n* upload repeat\n\nThe following will upload regularly for 20 seconds a file of 1Mo with download report each 2 seconds. Upload reports will appear in `onReport` callback of `IRepeatListener` instead of `onUploadProgress` :\n\n```java\nspeedTestSocket.startUploadRepeat(\"http://ipv4.ikoula.testdebit.info/\", 1000000\n    20000, 2000, new\n            IRepeatListener() {\n                @Override\n                public void onCompletion(final SpeedTestReport report) {\n                    // called when repeat task is finished\n                }\n\n                @Override\n                public void onReport(final SpeedTestReport report) {\n                    // called when an upload report is dispatched\n                }\n            });\n```\n\n### Get live download \u0026 upload\n\n* retrieve current download report : \n\n```java\nSpeedTestReport getLiveReport()\n```\n\n* retrieve current upload report : \n\n```java\nSpeedTestReport getLiveReport()\n```\n\n### Set setup time\n\nSetup time is the amount of time in milliseconds from which speed test will be calculated :\n\nThe following will set the setup time to 5 seconds which mean, the speed rate will begin to be computed 5 seconds after the speed test start :\n\n* download\n```java\nspeedTestSocket.setDownloadSetupTime(5000);\n```\n* upload\n```java\nspeedTestSocket.setUploadSetupTime(5000);\n```\n\n### Set upload file storage type\n\nBy default, data to be uploaded is stored in RAM, for large data it is recommended to used file storage : \n\n```java\nspeedTestSocket.setUploadStorageType(UploadStorageType.FILE_STORAGE);\n```\n\nIt will create a temporary file containing random data. File will be deleted automatically at the end of the upload.\n\n### Set size of each packet sent to upload server\n\n```java\nspeedTestSocket.setUploadChunkSize(65535);\n```\n\n### Set socket timeout value\n\nYou can set download/upload socket timeout in milliseconds :\n\n```java\nspeedTestSocket.setSocketTimeout(5000);\n```\n\n### Set transfer rate precision\n\nThese settings are used to alter transfer rate float rounding / scale :\n\n* set RoundingMode :\n\n```java\nspeedTestSocket.setDefaultRoundingMode(RoundingMode.HALF_EVEN);\n```\nDefault `RoundingMode` used for transfer rate calculation is `HALF_EVEN`. It can be override with : \n\n* set Scale :\n\n```java\nspeedTestSocket.setDefaultScale(4);\n```\nDefault scale used for transfer rate calculation is 4\n\n### FTP mode\n\nSet passive/active mode with :\n\n```java\nspeedTestSocket.setFtpMode(FtpMode.ACTIVE);\n```\n\ndefault is `FtpMode.PASSIVE`\n\n## Android Integration\n\n* add Internet permission to manifest : \n\n```xml\n\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n```\n\n* use an `AsyncTask` to run your speed test :\n\n```java\npublic class SpeedTestTask extends AsyncTask\u003cVoid, Void, String\u003e {\n\n    @Override\n    protected String doInBackground(Void... params) {\n\n        SpeedTestSocket speedTestSocket = new SpeedTestSocket();\n\n        // add a listener to wait for speedtest completion and progress\n        speedTestSocket.addSpeedTestListener(new ISpeedTestListener() {\n\n            @Override\n            public void onCompletion(SpeedTestReport report) {\n                // called when download/upload is finished\n                Log.v(\"speedtest\", \"[COMPLETED] rate in octet/s : \" + report.getTransferRateOctet());\n                Log.v(\"speedtest\", \"[COMPLETED] rate in bit/s   : \" + report.getTransferRateBit());\n            }\n\n            @Override\n            public void onError(SpeedTestError speedTestError, String errorMessage) {\n                // called when a download/upload error occur\n            }\n\n            @Override\n            public void onProgress(float percent, SpeedTestReport report) {\n                // called to notify download/upload progress\n                Log.v(\"speedtest\", \"[PROGRESS] progress : \" + percent + \"%\");\n                Log.v(\"speedtest\", \"[PROGRESS] rate in octet/s : \" + report.getTransferRateOctet());\n                Log.v(\"speedtest\", \"[PROGRESS] rate in bit/s   : \" + report.getTransferRateBit());\n            }\n        });\n\n        speedTestSocket.startDownload(\"http://ipv4.ikoula.testdebit.info/1M.iso\");\n\n        return null;\n    }\n}\n```\n\nExecute it with : `new SpeedTestTask().execute();`\n\n## Features examples\n\nAll following examples use speed test server `http://ipv4.ikoula.testdebit.info` for HTTP and `speedtest.tele2.net` for FTP\n\n* HTTP download (1Mo)\n\n```bash\n./gradlew downloadFile\n```\n\n* HTTP upload (1Mo)\n\n```bash\n./gradlew uploadFile\n```\n\n* FTP download (1Mo)\n\n```bash\n./gradlew downloadFTP\n```\n\n* FTP upload (1Mo)\n\n```bash\n./gradlew uploadFTP\n```\n\n* HTTP download (1Mo) through proxy server 216.56.48.118:9000 \n\n```bash\n./gradlew downloadFileProxy\n```\n\n* download during a fixed duration (size: 100Mo, duration: 15s, report interval: 1s)\n\n```bash\n./gradlew fixedDownload\n```\n\n* upload during a fixed duration (size: 100Mo, duration: 15s, report interval: 1s)\n\n```bash\n./gradlew fixedUpload\n```\n\n* download repeatedly a file during a fixed duration (size:10Mo, duration 11s, report interval: 1s)\n\n```bash\n./gradlew repeatDownload\n```\n\n* upload repeatedly a file during a fixed duration (size:1Mo, duration 11s, report interval: 1s)\n\n```bash\n./gradlew repeatUpload\n```\n\n* successive 2 x (download + upload) repeatedly a file during a fixed duration (1 download size:1Mo, duration 3s, report interval: 1s following by 1 upload size:1Mo, duration 3s, report interval: 1s)\n\n```bash\n./gradlew repeatChain\n```\n\n## Speed Test issues\n\nIt's important to choose an adequate speed test server depending on latency/jitter. This library is **not** responsible for the speed test server choice.\n\nNote that this library :\n* doesn't adjust the chunk size depending on the connection speed either\n* doesn't provide pre-estimation of the connection speed based on small chunk sent to/from server\n* doesn't detect anomaly either (for instance taking away X% slowest chunk and X% fastest chunk downloaded)\n\nThis library does provide an average of transfer rate for all individual chunks read/written for download/upload.\n\nThe 2 following links describe the process of speedtest.net :\n* http://www.ookla.com/support/a21110547/what-is-the-test-flow-and-methodology-for-the-speedtest\n* https://support.speedtest.net/hc/en-us/articles/203845400-How-does-the-test-itself-work-How-is-the-result-calculated-\n\n## Compatibility\n\nJRE 1.7 compliant\n\n## Build \u0026 test\n\n* build without test :\n\n```bash\n./gradlew clean build -x test\n```\n\n* build with test :\n\n```bash\n./gradlew clean build\n```\n\n* run specific test\n\n```bash\n./gradlew test --tests \"fr.bmartel.speedtest.test.SpeedTestFunctionalTest\"\n```\n\n## External libraries\n\n* [http-endec](https://github.com/bertrandmartel/http-endec)\n* [Apache Commons Net](https://commons.apache.org/proper/commons-net/)\n\n## License\n\nThe MIT License (MIT) Copyright (c) 2016-2018 Bertrand Martel\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrandmartel%2Fspeed-test-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbertrandmartel%2Fspeed-test-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrandmartel%2Fspeed-test-lib/lists"}