GithubHelp home page GithubHelp logo

magiclen / boyer-moore-magiclen Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 1.0 204 KB

Boyer-Moore-MagicLen, a fast string search algorithm implemented in Rust.

License: MIT License

Rust 100.00%
rust string-search boyer-moore

boyer-moore-magiclen's Introduction

Hi, welcome to my Github pages.

Things Related to My Projects

Rust JavaScript TypeScript Java C PHP Golang Bash

Ubuntu Server Linux Mint Android Windows

Tokio Rocket Axum napi-rs iced Node.js Webpack Express Fastify NestJS + Fastify Bootstrap Vite Vue.js Handlebars Tera Sass Nginx Apache httpd Docker

MySQL SQLite MongoDB Redis

boyer-moore-magiclen's People

Contributors

dependabot[bot] avatar magiclen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

atilogit

boyer-moore-magiclen's Issues

Maybe the algo can optimize?

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

panicked at 'attempt to subtract with overflow'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.