Crates.io | lcs_rs |
lib.rs | lcs_rs |
version | 0.1.1 |
source | src |
created_at | 2024-05-30 21:50:31.930767 |
updated_at | 2024-05-30 21:54:14.427247 |
description | Implementation of the longest common subsequence |
homepage | https://github.com/wiiznokes/lcs_rs/ |
repository | https://github.com/wiiznokes/lcs_rs.git |
max_upload_size | |
id | 1257303 |
size | 8,757 |
Longest common subsequence implementation in Rust (and Java).
let s1 = "GCACAGCGGT";
let s2 = "TTGTGAAATC";
assert!(lcs_rs::lcs(s1, s2) == "GAAT");
Todo: make benchmarks in a loop
Time: 687.737625ms
Time: 713.694264ms
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.
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.