-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove unneeded escaping in strings if possible (#253)
- Loading branch information
Showing
11 changed files
with
317 additions
and
138 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ members = [".", "crate/encstr"] | |
[workspace.package] | ||
repository = "https://github.com/pamburus/hl" | ||
authors = ["Pavel Ivanov <[email protected]>"] | ||
version = "0.29.3-alpha.1" | ||
version = "0.29.3" | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
|
@@ -135,6 +135,10 @@ harness = false | |
name = "json" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "mem" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "encstr" | ||
path = "benches/encstr/benches.rs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// std imports | ||
use std::alloc::System; | ||
|
||
// third-party imports | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use stats_alloc::{StatsAlloc, INSTRUMENTED_SYSTEM}; | ||
use std::hint::black_box; | ||
|
||
#[global_allocator] | ||
static GLOBAL: &StatsAlloc<System> = &INSTRUMENTED_SYSTEM; | ||
|
||
fn benchmark(c: &mut Criterion) { | ||
let mut c = c.benchmark_group("mem"); | ||
|
||
let bufs = |size| { | ||
let vi: Vec<u8> = (0..size).into_iter().map(|x| x as u8).collect(); | ||
let ve: Vec<u8> = Vec::with_capacity(size); | ||
(vi, ve) | ||
}; | ||
|
||
for n in [512, 4096] { | ||
c.bench_function(format!("mem-rotate-{}", n), |b| { | ||
let (mut vi, _) = bufs(n); | ||
b.iter(|| { | ||
black_box(&mut vi).rotate_right(1); | ||
}); | ||
}); | ||
c.bench_function(format!("mem-copy-{}", n), |b| { | ||
let (vi, mut ve) = bufs(n); | ||
b.iter(|| { | ||
ve.clear(); | ||
black_box(&mut ve).extend_from_slice(black_box(&vi).as_slice()); | ||
}); | ||
}); | ||
} | ||
|
||
c.bench_function("mem-find-single-value-4096", |b| { | ||
let vi: Vec<u8> = (0..4096).into_iter().map(|x| (x / 16) as u8).collect(); | ||
b.iter(|| { | ||
black_box(vi.iter().position(|&x| x == 128)); | ||
}); | ||
}); | ||
|
||
c.bench_function("mem-find-one-of-two-values-4096", |b| { | ||
let vi: Vec<u8> = (0..4096).into_iter().map(|x| (x / 16) as u8).collect(); | ||
b.iter(|| { | ||
black_box(vi.iter().position(|&x| matches!(x, 128 | 192))); | ||
}); | ||
}); | ||
|
||
c.bench_function("mem-find-one-of-four-values-4096", |b| { | ||
let vi: Vec<u8> = (0..4096).into_iter().map(|x| (x / 16) as u8).collect(); | ||
b.iter(|| { | ||
black_box(vi.iter().position(|&x| matches!(x, 128 | 192 | 224 | 240))); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.