Skip to content

Instantly share code, notes, and snippets.

View folkertdev's full-sized avatar

Folkert de Vries folkertdev

View GitHub Profile
@folkertdev
folkertdev / cargo-config.toml
Created January 12, 2025 16:00
use of the `stfle` instruction for s390x targets, to get the extended facility list
[build]
target = "s390x-unknown-linux-gnu"
[target.s390x-unknown-linux-gnu]
# runner = "qemu-s390x -cpu max -L /usr/s390x-linux-gnu"
runner = "qemu-s390x -cpu qemu,vx=on,vxeh=on,vxeh2=off -L /usr/s390x-linux-gnu"
# runner = "qemu-s390x -cpu z10EC -L /usr/s390x-linux-gnu"
linker = "s390x-linux-gnu-gcc"
@folkertdev
folkertdev / comrak_benchmark.rs
Created March 4, 2025 13:35
comrak_benchmark.rs
```rust
pub fn main() {
for _ in 0..100000 {
for email in INPUT {
let result = autolink_email(core::hint::black_box(email.as_bytes()));
}
}
}
const INPUT: &[&str] = &[
@folkertdev
folkertdev / main.rs
Created April 16, 2025 14:40
Profiling SIMD saturating subtract
const N: usize = 10000;
fn main() {
let mut args = std::env::args().skip(1); // skip the program name
// just get a bunch of arbitrary values cheaply
const INPUT: &[u8] = include_bytes!(
"/home/folkertdev/.cargo/registry/cache/github.com-1ecc6299db9ec823/clap-4.2.7.crate"
);
let (_, table, _) = unsafe { INPUT.align_to() };
@folkertdev
folkertdev / cortex-m-macro.rs
Created April 25, 2025 09:25
cfg macro example
#[unsafe(naked)]
extern "C" fn Reset() {
core::arch::naked_asm!(
// debug info
".cfi_sections .debug_frame",
".cfi_startproc",
// If enabled, initialise the SP. This is normally initialised by the CPU itself or by a
// bootloader, but some debuggers fail to set it when resetting the target, leading to
// stack corruptions.
#[cfg(feature = "set-sp")]
@folkertdev
folkertdev / Cargo.toml
Created May 21, 2025 14:29
benchmark `compare256` performance
[package]
name = "compare256-benchmark"
version = "0.1.0"
edition = "2024"
[dev-dependencies]
divan = "0.1.21"
[[bench]]
name = "compare256"