probably going to be slow for huge files. What are you using it for?
On Wednesday, April 22, 2015 at 2:25:27 AM UTC+12, Christophe-Marie
Duquesne wrote:
Hi,
I was looking for a rolling implementation of adler32, but I did not
find one with an interface I liked, so I wrote mine.
code: https://github.com/chmduquesne/rollinghash
doc: https://godoc.org/github.com/chmduquesne/rollinghash
To initialize the rolling window, just Write() it to the Hash. Then
you can just Roll() the entering byte to update the rolling hash. It
internally keeps (and updates) a copy of the rolling window in order
to determine the leaving byte.
I tested it with the same data as the vanilla package. The lib comes
with benchmarking code, to compare vanilla and rolling implementations
on 1024 and 128 bytes rolling windows:
% go test -bench .
PASS
BenchmarkVanillaKB 100000 17974 ns/op 56.97
MB/s
BenchmarkRollingKB 20000000 80.6 ns/op 12705.49
MB/s
BenchmarkVanilla128B 1000000 1059 ns/op 966.14
MB/s
BenchmarkRolling128B 50000000 77.6 ns/op 13195.44
MB/s
ok github.com/chmduquesne/rollinghash/adler32 8.767s
If you like it, use it!
Cheers,
Christophe-Marie Duquesne
--I was looking for a rolling implementation of adler32, but I did not
find one with an interface I liked, so I wrote mine.
code: https://github.com/chmduquesne/rollinghash
doc: https://godoc.org/github.com/chmduquesne/rollinghash
To initialize the rolling window, just Write() it to the Hash. Then
you can just Roll() the entering byte to update the rolling hash. It
internally keeps (and updates) a copy of the rolling window in order
to determine the leaving byte.
I tested it with the same data as the vanilla package. The lib comes
with benchmarking code, to compare vanilla and rolling implementations
on 1024 and 128 bytes rolling windows:
% go test -bench .
PASS
BenchmarkVanillaKB 100000 17974 ns/op 56.97
MB/s
BenchmarkRollingKB 20000000 80.6 ns/op 12705.49
MB/s
BenchmarkVanilla128B 1000000 1059 ns/op 966.14
MB/s
BenchmarkRolling128B 50000000 77.6 ns/op 13195.44
MB/s
ok github.com/chmduquesne/rollinghash/adler32 8.767s
If you like it, use it!
Cheers,
Christophe-Marie Duquesne
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.