一個以 Cloudflare 全球邊緣網路為測量引擎、Firebase 托管的商業級網路測速與診斷工具。除了測出下載、上傳、延遲、抖動與封包遺失,還會指出網路瓶頸在哪裡、對照台灣與全球平均值,並給出可執行的改善建議。
前端為單一自包含檔案 public/index.html,直接部署即可,無需建置流程。
- 即時圓形儀表 — 測試過程中速度數字與弧形進度即時跳動
- 六大核心指標 — 下載、上傳、延遲 Ping、抖動 Jitter、封包遺失、負載延遲,各自標示良好/普通/偏弱
- Bufferbloat(緩衝膨脹)分析 — 比較「閒置延遲」與「下載/上傳負載時延遲」的增量,並給 A/B/C/D 分級。這是「有人在用網路時全家變慢」的關鍵成因,多數測速工具不會測
- 問題診斷引擎 — 自動找出封包遺失、Bufferbloat、高延遲、高抖動、頻寬不足等問題,依嚴重度排序,每項附上白話說明與具體修正建議(例如啟用 SQM/QoS、改用有線)
- 市場平均比較 — 以長條圖對照「您的網路 / 台灣平均 / 全球平均」(業界典型參考值),一眼看出自己落在哪個水準
- 使用情境評估 — 4K 串流、視訊會議、競技遊戲、雲端遊戲、大檔上傳、多人同時使用,各自標示順暢/勉強可用/不建議
- 一鍵存成報告圖片(html2canvas)與重新測試
總分 0–100,由六項指標加權後計算,並套用「短板封頂」機制——只要有關鍵指標明顯偏弱(如封包遺失 > 2%、Bufferbloat > 150ms、延遲 > 120ms、抖動 > 50ms、下載 < 25Mbps),總分會被封頂,避免高頻寬掩蓋掉糟糕的穩定度。
| 分數 | 等級 | 說明 |
|---|---|---|
| 90–100 | 極佳 | 高畫質串流、視訊會議、線上遊戲可同時順跑 |
| 80–89 | 良好 | 適合絕大多數日常與多裝置使用 |
| 60–79 | 普通 | 基本使用足夠,高互動需求時可能偶有延遲 |
| 0–59 | 偏弱 | 有明顯瓶頸,建議依診斷報告改善 |
| 指標 | 良好 | 普通 | 偏弱 |
|---|---|---|---|
| 下載速度 | ≥ 95 Mbps | 25–95 Mbps | < 25 Mbps |
| 上傳速度 | ≥ 42 Mbps | 10–42 Mbps | < 10 Mbps |
| 延遲 Ping | ≤ 30 ms | 30–60 ms | > 60 ms |
| 抖動 Jitter | ≤ 10 ms | 10–30 ms | > 30 ms |
| 封包遺失 | ≤ 0.5% | 0.5–2% | > 2% |
| Bufferbloat(負載延遲增量) | ≤ 30 ms(A) | 30–150 ms(B/C) | > 150 ms(D) |
「台灣平均/全球平均」為業界典型參考值(概念參照 Ookla Speedtest Global Index 固網中位級距與 Cloudflare AIM 指標),供相對定位使用,非即時官方統計。單次測試會有波動,建議不同時段多測幾次取平均。
- 純 HTML / CSS / JavaScript(單一檔案,無建置流程)
- 測量引擎:
@cloudflare/speedtest(透過 skypack CDN 載入) - 報告截圖:html2canvas
- Firebase Hosting
cd public
python3 -m http.server 8000
# 開啟 http://localhost:8000(需連外網以載入 Cloudflare 測量引擎與 CDN 套件。)
firebase deploy專案部署於 Firebase Hosting:https://speedtest-75fb9.web.app
@cloudflare/speedtest is a JavaScript module to measure the quality of a client's Internet connection. It's the measurement engine that powers the Cloudflare speedtest measurement application available at https://speed.cloudflare.com.
The module performs test requests against the Cloudflare edge network and relies on the PerformanceResourceTiming browser api to extract timing results. The network connection is characterized by items such as download/upload bandwidth, latency and packet loss.
Please note that measurement results are collected by Cloudflare on completion for the purpose of calculating aggregated insights regarding Internet connection quality.
Add this package to your package.json by running this in the root of your project's directory:
npm install @cloudflare/speedtestimport SpeedTest from '@cloudflare/speedtest';
new SpeedTest().onFinish = results => console.log(results.getSummary());SpeedTest is a JavaScript Class and should be instantiated with the new keyword. It's not required to pass a config object, as all items have default values.
new SpeedTest({ configOptions })| Config option | Description | Default |
|---|---|---|
| autoStart: boolean | Whether to automatically start the measurements on instantiation. | true |
| downloadApiUrl: string | The URL of the API for performing download GET requests. | https://speed.cloudflare.com/__down |
| uploadApiUrl: string | The URL of the API for performing upload POST requests. | https://speed.cloudflare.com/__up |
| turnServerUri: string | The URI of the TURN server used to measure packet loss. | turn.speed.cloudflare.com:50000 |
| turnServerUser: string | The username for the TURN server credentials. | - |
| turnServerPass: string | The password for the TURN server credentials. | - |
| measurements: array | The sequence of measurements to perform by the speedtest engine. See below for the specific syntax of this option. | |
| measureDownloadLoadedLatency: boolean | Whether to perform additional latency measurements simultaneously with download requests, to measure loaded latency (during download). | true |
| measureUploadLoadedLatency: boolean | Whether to perform additional latency measurements simultaneously with upload requests, to measure loaded latency (during upload). | true |
| loadedLatencyThrottle: number | Time interval to wait in between loaded latency requests (in milliseconds). | 400 |
| bandwidthFinishRequestDuration: number | The minimum duration (in milliseconds) to reach in download/upload measurement sets for halting further measurements with larger file sizes in the same direction. | 1000 |
| estimatedServerTime: number | If the download/upload APIs do not return a server-timing response header containing the time spent in the server, this fixed value (in milliseconds) will be subtracted from all time-to-first-byte calculations. | 10 |
| latencyPercentile: number | The percentile (between 0 and 1) used to calculate latency from a set of measurements. | 0.5 |
| bandwidthPercentile: number | The percentile (between 0 and 1) used to calculate bandwidth from a set of measurements. | 0.9 |
| bandwidthMinRequestDuration: number | The minimum duration (in milliseconds) of a request to consider a measurement good enough to use in the bandwidth calculation. | 10 |
| loadedRequestMinDuration: number | The minimum duration (in milliseconds) of a request to consider it to be loading the connection. | 250 |
| loadedLatencyMaxPoints: number | The maximum number of data points to keep for loaded latency measurements. When more than this amount are available, the latest ones are kept. | 20 |
| Attribute | Description |
|---|---|
| results: Results | Getter of the current test results object. May yield incomplete values if the test is still running. |
| isRunning: boolean | Getter of whether the test engine is currently running. |
| isFinished: boolean | Getter of whether the test engine has finished all the measurements, and the results are considered final. |
| Method | Description |
|---|---|
| play() | Starts or resumes the measurements. Does nothing if the engine is already running or is finished. |
| pause() | Pauses the measurements. Does nothing if the engine is already paused or is finished. |
| restart() | Clears the current results and restarts the measurements from the beginning. |
| Event Method | Arguments | Description |
|---|---|---|
| onRunningChange | running: boolean | Invoked whenever the test engine starts or stops. The current state is included as a function argument. |
| onResultsChange | { type: string } | Invoked whenever any item changes in the results, usually indicating the completion of a measurement. The type of measurement that changed is included as an info attribute in the function argument. |
| onFinish | results: Results | Invoked whenever the test engine finishes all the measurements. The final results object is included as a function argument. |
| onError | error: string | Invoked whenever an error occurs during one of the measurements. The error details are included as a function argument. |
The specific measurements to be performed by the test engine (and their sequence) can be customized using the measurements config option. This should be an array of objects, each with a type field, plus additional fields specific to that measurement type.
The default set of measurements that is performed by the engine is:
[
{ type: 'latency', numPackets: 1 }, // initial latency estimation
{ type: 'download', bytes: 1e5, count: 1, bypassMinDuration: true }, // initial download estimation
{ type: 'latency', numPackets: 20 },
{ type: 'download', bytes: 1e5, count: 9 },
{ type: 'download', bytes: 1e6, count: 8 },
{ type: 'upload', bytes: 1e5, count: 8 },
{ type: 'packetLoss', numPackets: 1e3, responsesWaitTime: 3000 },
{ type: 'upload', bytes: 1e6, count: 6 },
{ type: 'download', bytes: 1e7, count: 6 },
{ type: 'upload', bytes: 1e7, count: 4 },
{ type: 'download', bytes: 2.5e7, count: 4 },
{ type: 'upload', bytes: 2.5e7, count: 4 },
{ type: 'download', bytes: 1e8, count: 3 },
{ type: 'upload', bytes: 5e7, count: 3 },
{ type: 'download', bytes: 2.5e8, count: 2 }
]Here are the fields available per measurement type:
| Field | Required | Description | Default |
|---|---|---|---|
| numPackets: number | yes | The number of latency GET requests to perform. These requests are performed against the download API with bytes=0, and then the round-trip time-to-first-byte timing between requestStart and responseStart is extracted. |
- |
Each of these measurement sets are bound to a specific file size. The engine follows a ramp-up methodology per direction (download or upload). Whenever there are multiple measurement sets (with increasing file sizes) for a direction, the engine will keep on performing them until it reaches the condition specified by bandwidthMinRequestDuration, at which point further sets in the same direction are ignored.
| Field | Required | Description | Default |
|---|---|---|---|
| bytes: number | yes | The file size to request from the download API, or post to the upload API. The bandwidth (calculated as bits per second, or bps) for each request is calculated by dividing the transferSize (in bits) by the request duration (excluding the server processing time). |
- |
| count: number | yes | The number of requests to perform for this file size. | - |
| bypassMinDuration: boolean | no | Whether the bandwidthMinRequestDuration check should be ignored, and the engine is instructed to proceed with the measurements of this direction in any case. |
false |
Packet loss is measured by submitting a set of UDP packets to a WebRTC TURN server in a round-trip fashion, and determining how many packets do not arrive. The submission of these packets can be done in a batching method, in which there's a sleep time in between batches.
| Field | Required | Description | Default |
|---|---|---|---|
| numPackets: number | no | The total number of UDP packets to send. | 100 |
| responsesWaitTime: number | no | The interval of time (in milliseconds) to wait after the latest packet reception before determining the measurement as complete, and all non-returned packets as lost. | 5000 |
| batchSize: number | no | The number of packets in a batch. If this value is higher than numPackets there will be only one batch. |
10 |
| batchWaitTime: number | no | How long to wait (in milliseconds) between batches. | 10 |
| connectionTimeout: number | no | Timeout for the connection to the TURN server. | 5000 |
An instance object used to access the results of the speedtest measurements. The following methods are available on this object:
| Method | Description |
|---|---|
| getSummary() | Returns a high-level summary object with the computed results from the performed measurements. |
| getUnloadedLatency() | Returns the reduced value of the connection latency while at idle. Requires at least one latency measurement. |
| getUnloadedJitter() | Returns the connection jitter while at idle. Jitter is calculated as the average distance between consecutive latency measurements. Requires at least two latency measurements. |
| getUnloadedLatencyPoints() | Returns an array with all the latencies measured while at idle. Includes one value per measurement in sequence. |
| getDownLoadedLatency() | Returns the reduced value of the connection latency while loaded in the download direction. Requires measureDownloadLoadedLatency to be enabled. |
| getDownLoadedJitter() | Returns the connection jitter while loaded in the download direction. Requires measureDownloadLoadedLatency to be enabled, and at least two loaded latency measurements. |
| getDownLoadedLatencyPoints() | Returns an array with all the latencies measured while loaded in the download direction. Includes one value per loaded measurement in sequence. Requires measureDownloadLoadedLatency to be enabled. |
| getUpLoadedLatency() | Returns the reduced value of the connection latency while loaded in the upload direction. Requires measureUploadLoadedLatency to be enabled. |
| getUpLoadedJitter() | Returns the connection jitter while loaded in the upload direction. Requires measureUploadLoadedLatency to be enabled, and at least two loaded latency measurements. |
| getUpLoadedLatencyPoints() | Returns an array with all the latencies measured while loaded in the upload direction. Includes one value per loaded measurement in sequence. Requires measureUploadLoadedLatency to be enabled. |
| getDownloadBandwidth() | Returns the reduced value of the download bandwidth (in bps). Requires at least one download measurement, longer than the bandwidthMinRequestDuration threshold. |
| getDownloadBandwidthPoints() | Returns an array with all the download measurement results. Each item will include the following fields: { bytes, bps, duration, ping, measTime, serverTime, transferSize }. |
| getUploadBandwidth() | Returns the reduced value of the upload bandwidth (in bps). Requires at least one upload measurement, longer than the bandwidthMinRequestDuration threshold. |
| getUploadBandwidthPoints() | Returns an array with all the upload measurement results. Each item will include the following fields: { bytes, bps, duration, ping, measTime, serverTime, transferSize }. |
| getPacketLoss() | Returns the reduced value of the measured packet loss ratio (between 0 and 1). Requires a packetLoss measurement set. |
| getPacketLossDetails() | Returns an object with the details of the packet loss measurement. Includes the following fields: { packetLoss, totalMessages, numMessagesSent, lostMessages }. Requires a packetLoss measurement set. |
| getScores() | Returns the computed AIM scores that categorize the quality of the network connection according to use cases such as streaming, gaming or real-time communications. This score is only available after the engine has finished performing all of the measurements. |