Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark findcipher and minor optimization #7

Merged
merged 8 commits into from
Dec 12, 2018
Merged

Benchmark findcipher and minor optimization #7

merged 8 commits into from
Dec 12, 2018

Conversation

fortuna
Copy link

@fortuna fortuna commented Dec 12, 2018

Example run:

$ go test -cpuprofile cpu.prof -memprofile mem.prof -bench . -benchmem -run=^$ github.com/Jigsaw-Code/outline-ss-server/shadowsocks
goos: linux
goarch: amd64
pkg: github.com/Jigsaw-Code/outline-ss-server/shadowsocks
BenchmarkTCPFindCipher-12    	    1000	   2397037 ns/op	 2026516 B/op	    3013 allocs/op
BenchmarkUDPUnpack-12        	    2000	    892407 ns/op	  125029 B/op	    1701 allocs/op

I'm getting ~2ms to go over 100 ciphers. It makes 3013 allocations for a total of 2MB.

With 1 cipher:

BenchmarkTCPFindCipher-12    	   20000	     63841 ns/op	   20451 B/op	      33 allocs/op
BenchmarkUDPUnpack-12        	  100000	     12803 ns/op	    1280 B/op	      18 allocs/op

To inspect the details of the profile:

go tool pprof mem.prof

(then type web)

@fortuna fortuna requested a review from trevj December 12, 2018 17:03
@fortuna fortuna self-assigned this Dec 12, 2018
Copy link

@trevj trevj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@fortuna fortuna merged commit 759776a into master Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants