Skip to content

Instantly share code, notes, and snippets.

View Dousir9's full-sized avatar
🎯
Focusing

Jk Xu Dousir9

🎯
Focusing
View GitHub Profile
@Dousir9
Dousir9 / vec_bench_stack_value.rs
Last active September 30, 2023 14:59
vec_bench(stack value)
use criterion::{criterion_group, criterion_main, Criterion};
use rand::Rng;
/// # Safety
///
/// * `ptr` must be [valid] for writes.
/// * `ptr` must be properly aligned.
#[inline(always)]
pub unsafe fn store_advance_aligned<T>(val: T, ptr: &mut *mut T) {
unsafe {
@Dousir9
Dousir9 / vec_bench.rs
Created September 30, 2023 05:32
Vec Bench
use std::time::Instant;
/// # Safety
///
/// * `ptr` must be [valid] for writes.
/// * `ptr` must be properly aligned.
#[inline(always)]
pub unsafe fn store_advance_aligned<T>(val: T, ptr: &mut *mut T) {
unsafe {
std::ptr::write(*ptr, val);