Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --release
- run: cargo test

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo clippy -- -D warnings
- run: cargo fmt --check
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

on:
push:
tags: ["v*"]

permissions:
contents: write

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../fledge-plugin-speedtest-${{ matrix.target }}.tar.gz fledge-speedtest
- name: Package (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../fledge-plugin-speedtest-${{ matrix.target }}.zip fledge-speedtest.exe
- uses: softprops/action-gh-release@v2
with:
files: |
fledge-plugin-speedtest-*.tar.gz
fledge-plugin-speedtest-*.zip
26 changes: 6 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@ const UP_URL: &str = "https://speed.cloudflare.com/__up";
/// on fast links. We rotate through the list, repeating until --duration is up.
/// Upload sizes are capped lower because Cloudflare's `__up` endpoint resets
/// the connection on very large bodies.
const DOWNLOAD_SIZES: &[u64] = &[
100_000,
1_000_000,
10_000_000,
25_000_000,
100_000_000,
];

const UPLOAD_SIZES: &[u64] = &[
100_000,
1_000_000,
10_000_000,
];
const DOWNLOAD_SIZES: &[u64] = &[100_000, 1_000_000, 10_000_000, 25_000_000, 100_000_000];

const UPLOAD_SIZES: &[u64] = &[100_000, 1_000_000, 10_000_000];

const WARMUP_BYTES: u64 = 100_000;
const DEFAULT_DURATION_SECS: u64 = 10;
Expand Down Expand Up @@ -155,7 +145,8 @@ fn measure_latency(client: &Client, show_progress: bool) -> Result<f64> {
.send()
.context("latency probe")?;
let mut sink = Vec::new();
resp.read_to_end(&mut sink).context("draining latency probe")?;
resp.read_to_end(&mut sink)
.context("draining latency probe")?;
let ms = start.elapsed().as_secs_f64() * 1000.0;
if ms < best {
best = ms;
Expand Down Expand Up @@ -259,12 +250,7 @@ fn measure_upload(client: &Client, window: Duration, show_progress: bool) -> Res
let stop_clone = Arc::clone(&stop);
let handle = thread::spawn(move || {
while !stop_clone.load(Ordering::Relaxed) {
draw_progress_label(
"Upload",
start.elapsed().min(window),
window,
&label,
);
draw_progress_label("Upload", start.elapsed().min(window), window, &label);
thread::sleep(PROGRESS_TICK);
}
});
Expand Down
Loading