lcs_rs

Crates.iolcs_rs
lib.rslcs_rs
version0.1.1
sourcesrc
created_at2024-05-30 21:50:31.930767
updated_at2024-05-30 21:54:14.427247
descriptionImplementation of the longest common subsequence
homepagehttps://github.com/wiiznokes/lcs_rs/
repositoryhttps://github.com/wiiznokes/lcs_rs.git
max_upload_size
id1257303
size8,757
(wiiznokes)

documentation

README

lcs_rs

crates.io docs.rs license

Longest common subsequence implementation in Rust (and Java).

Usage

let s1 = "GCACAGCGGT";
let s2 = "TTGTGAAATC";

assert!(lcs_rs::lcs(s1, s2) == "GAAT");

bench for the 10000-10000 test

Todo: make benchmarks in a loop

Rust

Time: 687.737625ms
Time: 713.694264ms

Java

Time: 623.69858 millis
Time: 668.713163 millis

This result varies ~ += 50 ms on my pc.

None of both implementations have been hardly optimized, but the algorithm used is quite fast.

Attempt to explain why rust is slower (please don't quote me on this)

Maybe the JVM allocates some space directly when launching the program, which makes the allocation of the matrix faster.

Rust needs to iterate over all chars to get the number of chars in the string, because an UTF-8 can have different sizes. I don't think Java does this.

Commit count: 18

cargo fmt