Hi, welcome to my Github pages.
magiclen / boyer-moore-magiclen Goto Github PK
View Code? Open in Web Editor NEWBoyer-Moore-MagicLen, a fast string search algorithm implemented in Rust.
License: MIT License
Boyer-Moore-MagicLen, a fast string search algorithm implemented in Rust.
License: MIT License
helloπ git:(master) β‘ cat src/main.rs
use std::time::Instant;
use boyer_moore_magiclen::BMByte;
/*
fn main() {
let needle = (0..100).map(|_| "b").collect::<String>();
let heystack = (0..100_000).map(|_| "a").collect::<String>();
println!("Data ready.");
let now = Instant::now();
for _ in 0..1_000_000 {
if heystack.find(&needle).is_some() { }
}
let ned = Instant::now();
println!("cost:{:?}", ned-now);
}
*/
fn main() {
let needle = (0..100).map(|_| "b").collect::<String>();
let heystack = (0..100_000).map(|_| "a").collect::<String>();
println!("Data ready.");
let now = Instant::now();
let bmb = BMByte::from(needle).unwrap();
for _ in 0..1_000_000 {
if bmb.find_first_in(&heystack).is_some() {}
}
let ned = Instant::now();
println!("cost:{:?}", ned-now);
}
helloπ git:(master) β‘ cargo run -r
Finished release [optimized] target(s) in 0.01s
Running `target/release/hello`
Data ready.
cost:4.293501137s
On my local, std::find just cost 1.381615965s
Hello,
I got a crash with following code
let pattern = BMByte::from("CreateFile").expect("boyer_moore_pattern");
pattern.rfind_full_all_in("0_000_000 0008:0009:trace:rela");
text bytes [48, 95, 48, 48, 48, 95, 48, 48, 48, 32, 32, 32, 32, 48, 48, 48, 56, 58, 48, 48, 48, 57, 58, 116, 114, 97, 99, 101, 58, 114, 101, 108, 97]
stacktrace
14: 0x562c293b8842 - boyer_moore_magiclen::byte::rfind_full::h0314f9d622769392
.cargo/registry/src/github.com-1ecc6299db9ec823/boyer-moore-magiclen-0.2.10/src/byte.rs:396
15: 0x562c293b9069 - boyer_moore_magiclen::byte::BMByte::rfind_full_all_in::h05acc3dc093adc04
.cargo/registry/src/github.com-1ecc6299db9ec823/boyer-moore-magiclen-0.2.10/src/byte.rs:276
Because I don't want to create a Vec<u8>
when I got a slice of [u8] or something that can be derefed to a slice of bytes like MMap.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.