Skip to content

examples/perf: Add an arch flag to run only on x86_64 #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@1.85 # do clippy chekcs with the minimum supported version
- uses: dtolnay/rust-toolchain@1.88 # do clippy chekcs with the minimum supported version
with:
components: rustfmt, clippy

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@1.85
- uses: dtolnay/rust-toolchain@1.88
with:
components: llvm-tools-preview

Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@1.85
- uses: dtolnay/rust-toolchain@1.88
with:
targets: wasm32-wasip1

Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simd-json"
version = "0.15.1"
version = "0.16.0"
authors = ["Heinz N. Gies <heinz@licenser.net>", "Sunny Gleason"]
edition = "2024"
exclude = ["data/*", "fuzz/*"]
Expand All @@ -9,7 +9,7 @@ description = "High performance JSON parser based on a port of simdjson"
repository = "https://github.com/simd-lite/simd-json"
readme = "README.md"
documentation = "https://docs.rs/simd-json"
rust-version = "1.85"
rust-version = "1.88"

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }
Expand All @@ -33,6 +33,8 @@ alloc_counter = { version = "0.0.4", optional = true }
colored = { version = "3.0", optional = true }
getopts = { version = "0.2", optional = true }
jemallocator = { version = "0.5", optional = true }

[target.'cfg(target_arch = "x86_64")'.dependencies]
perfcnt = { version = "0.8", optional = true }

ref-cast = "1.0"
Expand Down
10 changes: 7 additions & 3 deletions examples/perf.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::env;

#[cfg(feature = "perf")]
#[cfg(all(feature = "perf", target_arch = "x86_64", target_os = "linux"))]
mod int {
const ROUNDS: usize = 2000;
const WARMUP: usize = 200;
Expand Down Expand Up @@ -216,10 +216,14 @@ mod int {
}
}

#[cfg(not(feature = "perf"))]
#[cfg(not(all(feature = "perf", target_arch = "x86_64", target_os = "linux")))]
mod int {
pub fn bench(_name: &str, _baseline: bool) {
println!("Perf requires linux to run and the perf feature to be enabled")
if std::env::consts::ARCH != "x86_64" {
println!("This Perf example only supports x86_64 for now.");
} else if std::env::consts::OS != "linux" {
println!("Perf requires linux to run and the perf feature to be enabled");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)]
#![allow(
clippy::module_name_repetitions,
unused_unsafe // for nightly
unused_unsafe, // for nightly
)]
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]

Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ pub(crate) use unlikely;
#[allow(unused_macros)]
macro_rules! static_cast_i32 {
($v:expr_2021) => {
::std::mem::transmute::<u32, i32>($v)
u32::cast_signed($v)
};
}
#[allow(unused_imports)]
Expand All @@ -1243,7 +1243,7 @@ pub(crate) use static_cast_u32;
/// static cast to an i64
macro_rules! static_cast_i64 {
($v:expr_2021) => {
::std::mem::transmute::<u64, i64>($v)
u64::cast_signed($v)
};
}
pub(crate) use static_cast_i64;
Expand All @@ -1261,7 +1261,7 @@ pub(crate) use static_cast_i128;
/// static cast to an u64
macro_rules! static_cast_u64 {
($v:expr_2021) => {
::std::mem::transmute::<i64, u64>($v)
i64::cast_unsigned($v)
};
}
pub(crate) use static_cast_u64;
Expand Down
Loading