JuliaPerf / BenchmarksGame.jl

Other
43 stars 13 forks source link

improve performance in knucleotide by specializing on lenght #19

Closed KristofferC closed 5 years ago

KristofferC commented 5 years ago

Before:

   knucleotide-fast.jl        1    20.4s   100%

After:

   knucleotide-fast.jl        1    16.0s   100%
KristofferC commented 5 years ago

Re-running it and the performance difference is quite small now.

chethega commented 5 years ago

Not sure whether this is permissible, but one could turn the string input into a UInt64[] on parsing (two bits per entry) and move the sliding window by simple shifts (need to fill in new content every 32 - length steps). If encoding of a subsequence as an integer is permissible, then shifting the window is surely permissible as well?

KristofferC commented 5 years ago

You only need to subtract the first nucleotide in the chain and the most recently read one?

So if you have k = "GA" and you read a T you do something like k - 'G' + 'T'. Should be an ok optimization.