Compare commits

..

No commits in common. "4092239dd9e807e6034b0311fe8513394d60a2fe" and "a6b4bfbb1e379038a0127b013a84b2f885c08fc9" have entirely different histories.

4 changed files with 18 additions and 66 deletions

View file

@ -1,31 +1,11 @@
name: Cargo Format, Check and Test name: Cargo Check and Test
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
format:
name: cargo test
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt
- uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Automatical formatting
check:
name: cargo test
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --all-features --verbose
test: test:
name: cargo test name: cargo test
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- run: cargo check --all-features --verbose
- run: cargo test --all-features --verbose - run: cargo test --all-features --verbose

View file

@ -1,58 +1,31 @@
#![allow(unused)] #![allow(unused)]
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use criterion::{black_box, criterion_group, criterion_main, Criterion, BenchmarkId, Throughput};
use revsqrt::{fast_inverse_sqrt, inverse_sqrt}; use revsqrt::{inverse_sqrt, fast_inverse_sqrt};
const SIZE: f32 = 1337.1337; const SIZE: f32 = 1337.1337;
const FCONST: f32 = 1024.12481224; const FCONST: f32 = 1024.12481224;
const FCONST1: f32 = 4025.724812234; const FCONST1: f32 = 4025.724812234;
pub fn single_input(c: &mut Criterion) { pub fn single_input(c: &mut Criterion) {
c.bench_with_input(BenchmarkId::new("regular rsqrt", SIZE), &SIZE, |b, &s| { c.bench_with_input(BenchmarkId::new("regular rsqrt", SIZE),&SIZE, |b, &s| b.iter(|| inverse_sqrt(s)));
b.iter(|| inverse_sqrt(s)) c.bench_with_input(BenchmarkId::new("fast rsqrt", SIZE),&SIZE, |b, &s| b.iter(|| fast_inverse_sqrt(s)));
});
c.bench_with_input(BenchmarkId::new("fast rsqrt", SIZE), &SIZE, |b, &s| {
b.iter(|| fast_inverse_sqrt(s))
});
} }
pub fn multi_input(c: &mut Criterion) { pub fn multi_input(c: &mut Criterion) {
let mut group = c.benchmark_group("multi_input"); let mut group = c.benchmark_group("multi_input");
for size in [ for size in [FCONST, 2.2 * FCONST, 4.24 * FCONST, 8.64 * FCONST, 16.12 * FCONST].iter() {
FCONST,
2.2 * FCONST,
4.24 * FCONST,
8.64 * FCONST,
16.12 * FCONST,
]
.iter()
{
group.throughput(Throughput::Bytes(*size as u64)); group.throughput(Throughput::Bytes(*size as u64));
group.bench_with_input( group.bench_with_input(BenchmarkId::new("regular rsqrt mixed input", FCONST), size, |b, &size| {
BenchmarkId::new("regular rsqrt mixed input", FCONST),
size,
|b, &size| {
b.iter(||inverse_sqrt(size)); b.iter(||inverse_sqrt(size));
}, });
);
} }
for size in [ for size in [FCONST1, 2.2 * FCONST1, 4.24 * FCONST1, 8.64 * FCONST1, 16.12 * FCONST1].iter() {
FCONST1,
2.2 * FCONST1,
4.24 * FCONST1,
8.64 * FCONST1,
16.12 * FCONST1,
]
.iter()
{
group.throughput(Throughput::Bytes(*size as u64)); group.throughput(Throughput::Bytes(*size as u64));
group.bench_with_input( group.bench_with_input(BenchmarkId::new("fast rsqrt mixed input", FCONST1), size, |b, &size| {
BenchmarkId::new("fast rsqrt mixed input", FCONST1),
size,
|b, &size| {
b.iter(||fast_inverse_sqrt(size)); b.iter(||fast_inverse_sqrt(size));
}, });
);
} }
group.finish(); group.finish();
} }
criterion_group!(benches, single_input, multi_input); criterion_group!(benches, single_input, multi_input);
criterion_main!(benches); criterion_main!(benches);

View file

@ -8,6 +8,5 @@ Select your target like this:
To see a list of all runnable binaries, you can use the following command. To see a list of all runnable binaries, you can use the following command.
`cargo run --bin` `cargo run --bin`
" ");
);
} }