dreadl0ck / ja3

Go package for Ja3 TLS client and server hello fingerprints
BSD 3-Clause "New" or "Revised" License
144 stars 21 forks source link

reduced allocations in Bare for big speedup #1

Closed guigzzz closed 5 years ago

guigzzz commented 5 years ago

Benchmark running on a 7700HQ laptop

goos: windows
goarch: amd64
BenchmarkDigestHexPacket-8       1000000          1287 ns/op         464 B/op         13 allocs/op
BenchmarkDigestPacket-8          1000000          1192 ns/op         400 B/op         11 allocs/op
BenchmarkBarePacket-8            2000000           920 ns/op         400 B/op         11 allocs/op
BenchmarkDigestHex-8             2000000           767 ns/op         256 B/op          3 allocs/op
BenchmarkDigest-8                2000000           675 ns/op         192 B/op          1 allocs/op
BenchmarkBare-8                  3000000           428 ns/op         192 B/op          1 allocs/op
PASS
coverage: 36.5% of statements

This can still be improved, see TODO in Bare function

dreadl0ck commented 5 years ago

Awesome, great job! Thanks :)

dreadl0ck commented 5 years ago

I've updated the benchmarks and added length checks in case the arrays are empty, to prevent accessing the index -1.

Thanks again for your contribution!