Skip to content

Commit

Permalink
Merge pull request #55 from messense/mips
Browse files Browse the repository at this point in the history
Use `fetch_update` to support mock on 32-bit MIPS and ARMv5TE
  • Loading branch information
tobz authored Sep 12, 2021
2 parents 9ec21c5 + ff88d73 commit fb8e29e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust_version: ['1.45.0', 'stable', 'nightly']
rust_version: ['1.51.0', 'stable', 'nightly']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -35,6 +35,32 @@ jobs:
override: true
- name: Run Tests
run: cargo test --no-default-features --features=prost -- --test-threads=1
cross-test:
name: Test ${{ matrix.rust_version }}/${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
rust_version: ['stable']
target:
- aarch64-unknown-linux-gnu
- armv5te-unknown-linux-gnueabi
- arm-unknown-linux-gnueabi
- armv7-unknown-linux-gnueabihf
- mips-unknown-linux-gnu
- mipsel-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ matrix.rust_version }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_version }}
target: ${{ matrix.target }}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --target ${{ matrix.target }} --no-default-features --features=prost -- --test-threads=1
bench:
name: Bench ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
10 changes: 8 additions & 2 deletions src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ impl Mock {

/// Increments the time by the given amount.
pub fn increment<N: IntoNanoseconds>(&self, amount: N) {
self.offset.fetch_add(amount.into_nanos());
let amount = amount.into_nanos();
self.offset
.fetch_update(|current| Some(current + amount))
.unwrap();
}

/// Decrements the time by the given amount.
pub fn decrement<N: IntoNanoseconds>(&self, amount: N) {
self.offset.fetch_sub(amount.into_nanos());
let amount = amount.into_nanos();
self.offset
.fetch_update(|current| Some(current - amount))
.unwrap();
}

/// Gets the current value of this `Mock`.
Expand Down

4 comments on commit fb8e29e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bench-macOS-latest

Benchmark suite Current: fb8e29e Previous: 893337f Ratio
stdlib/instant_now 17 ns/iter (± 0) 18 ns/iter (± 0) 0.94
stdlib/instant_delta 58 ns/iter (± 0) 61 ns/iter (± 1) 0.95
quanta/quanta_now 18 ns/iter (± 0) 19 ns/iter (± 2) 0.95
quanta/quanta_now_delta 38 ns/iter (± 0) 40 ns/iter (± 2) 0.95
quanta/quanta_instant_now 22 ns/iter (± 0) 23 ns/iter (± 2) 0.96
quanta/quanta_raw 11 ns/iter (± 0) 12 ns/iter (± 0) 0.92
quanta/quanta_raw_scaled 15 ns/iter (± 0) 15 ns/iter (± 0) 1
quanta/quanta_raw_delta 27 ns/iter (± 0) 29 ns/iter (± 1) 0.93
quanta/quanta_start 17 ns/iter (± 0) 18 ns/iter (± 0) 0.94
quanta/quanta_start_scaled 20 ns/iter (± 0) 21 ns/iter (± 0) 0.95
quanta/quanta_end 18 ns/iter (± 0) 19 ns/iter (± 1) 0.95
quanta/quanta_end_scaled 21 ns/iter (± 0) 22 ns/iter (± 1) 0.95
quanta/quanta_start/end_delta 39 ns/iter (± 0) 41 ns/iter (± 2) 0.95
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bench-ubuntu-latest

Benchmark suite Current: fb8e29e Previous: 9ec21c5 Ratio
stdlib/instant_now 30 ns/iter (± 0) 28 ns/iter (± 1) 1.07
stdlib/instant_delta 66 ns/iter (± 1) 64 ns/iter (± 3) 1.03
quanta/quanta_now 29 ns/iter (± 0) 25 ns/iter (± 1) 1.16
quanta/quanta_now_delta 58 ns/iter (± 2) 54 ns/iter (± 2) 1.07
quanta/quanta_instant_now 32 ns/iter (± 1) 31 ns/iter (± 2) 1.03
quanta/quanta_raw 18 ns/iter (± 0) 17 ns/iter (± 0) 1.06
quanta/quanta_raw_scaled 24 ns/iter (± 0) 23 ns/iter (± 0) 1.04
quanta/quanta_raw_delta 47 ns/iter (± 1) 42 ns/iter (± 2) 1.12
quanta/quanta_start 26 ns/iter (± 0) 22 ns/iter (± 1) 1.18
quanta/quanta_start_scaled 31 ns/iter (± 0) 29 ns/iter (± 2) 1.07
quanta/quanta_end 26 ns/iter (± 0) 23 ns/iter (± 0) 1.13
quanta/quanta_end_scaled 30 ns/iter (± 1) 28 ns/iter (± 1) 1.07
quanta/quanta_start/end_delta 55 ns/iter (± 2) 54 ns/iter (± 5) 1.02
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'bench-macOS-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 0.1.

Benchmark suite Current: fb8e29e Previous: 893337f Ratio
stdlib/instant_now 17 ns/iter (± 0) 18 ns/iter (± 0) 0.94
stdlib/instant_delta 58 ns/iter (± 0) 61 ns/iter (± 1) 0.95
quanta/quanta_now 18 ns/iter (± 0) 19 ns/iter (± 2) 0.95
quanta/quanta_now_delta 38 ns/iter (± 0) 40 ns/iter (± 2) 0.95
quanta/quanta_instant_now 22 ns/iter (± 0) 23 ns/iter (± 2) 0.96
quanta/quanta_raw 11 ns/iter (± 0) 12 ns/iter (± 0) 0.92
quanta/quanta_raw_scaled 15 ns/iter (± 0) 15 ns/iter (± 0) 1
quanta/quanta_raw_delta 27 ns/iter (± 0) 29 ns/iter (± 1) 0.93
quanta/quanta_start 17 ns/iter (± 0) 18 ns/iter (± 0) 0.94
quanta/quanta_start_scaled 20 ns/iter (± 0) 21 ns/iter (± 0) 0.95
quanta/quanta_end 18 ns/iter (± 0) 19 ns/iter (± 1) 0.95
quanta/quanta_end_scaled 21 ns/iter (± 0) 22 ns/iter (± 1) 0.95
quanta/quanta_start/end_delta 39 ns/iter (± 0) 41 ns/iter (± 2) 0.95
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

CC: @metrics-rs/maintainers

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'bench-ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 0.1.

Benchmark suite Current: fb8e29e Previous: 9ec21c5 Ratio
stdlib/instant_now 30 ns/iter (± 0) 28 ns/iter (± 1) 1.07
stdlib/instant_delta 66 ns/iter (± 1) 64 ns/iter (± 3) 1.03
quanta/quanta_now 29 ns/iter (± 0) 25 ns/iter (± 1) 1.16
quanta/quanta_now_delta 58 ns/iter (± 2) 54 ns/iter (± 2) 1.07
quanta/quanta_instant_now 32 ns/iter (± 1) 31 ns/iter (± 2) 1.03
quanta/quanta_raw 18 ns/iter (± 0) 17 ns/iter (± 0) 1.06
quanta/quanta_raw_scaled 24 ns/iter (± 0) 23 ns/iter (± 0) 1.04
quanta/quanta_raw_delta 47 ns/iter (± 1) 42 ns/iter (± 2) 1.12
quanta/quanta_start 26 ns/iter (± 0) 22 ns/iter (± 1) 1.18
quanta/quanta_start_scaled 31 ns/iter (± 0) 29 ns/iter (± 2) 1.07
quanta/quanta_end 26 ns/iter (± 0) 23 ns/iter (± 0) 1.13
quanta/quanta_end_scaled 30 ns/iter (± 1) 28 ns/iter (± 1) 1.07
quanta/quanta_start/end_delta 55 ns/iter (± 2) 54 ns/iter (± 5) 1.02
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

CC: @metrics-rs/maintainers

Please sign in to comment.