Commit Graph

3 Commits

Author SHA1 Message Date
Tevin Zhang 0d34068678 Use 10.255.255.1:80 as an always-timeout address
Since 10.0.0.0:1 causes ErrConnect(permission denied) instead of ErrTimeout in Travis CI's macOS environment.
2019-02-13 11:05:36 +08:00
Tevin Zhang b0f2b6a708 Add benchmarks
go version go1.11.4 linux/amd64

goos: linux
goarch: amd64
pkg: github.com/tevino/tcp-shaker
BenchmarkPipePoolDummyOK-32              	  300000	      4002 ns/op	     660 B/op	      16 allocs/op
BenchmarkPipePoolSyncPoolOK-32           	  300000	      3955 ns/op	     507 B/op	      14 allocs/op
BenchmarkPipePoolDummyErr-32             	  300000	      4026 ns/op	     613 B/op	      16 allocs/op
BenchmarkPipePoolSyncPoolErr-32          	  300000	      3973 ns/op	     526 B/op	      14 allocs/op
BenchmarkPipePoolDummyTimeout-32         	  300000	      3954 ns/op	     613 B/op	      16 allocs/op
BenchmarkPipePoolSyncPoolTimeout-32      	  300000	      3895 ns/op	     507 B/op	      14 allocs/op
BenchmarkResultPipesMUOK-32              	  300000	      4692 ns/op	     478 B/op	      12 allocs/op
BenchmarkResultPipesSyncMapOK-32         	  300000	      3902 ns/op	     506 B/op	      14 allocs/op
BenchmarkResultPipesMUErr-32             	  300000	      4399 ns/op	     478 B/op	      12 allocs/op
BenchmarkResultPipesSyncMapErr-32        	  300000	      3993 ns/op	     508 B/op	      14 allocs/op
BenchmarkResultPipesMUTimeout-32         	  300000	      4473 ns/op	     478 B/op	      12 allocs/op
BenchmarkResultPipesSyncMapTimeout-32    	  300000	      3947 ns/op	     507 B/op	      14 allocs/op
2019-02-12 19:03:06 +08:00
Tevin Zhang a89fc1fe18 Refactor
Significant changes:

1. `NewChecker()` accepts no argument, `zeroLinger` is enabled by default
2. Optional parameter `zeroLinger` in `CheckAddr()` turned into `CheckerAddrZeroLinger()`
3. `InitChecker()` -> `CheckingLoop(context)`
4. `ErrNotInitialized` -> `ErrCheckerAlreadyStarted`
5. Fewer system call calling, e.g. `connect()` is called exactly once per check
6. Epoll is now edge-triggered
2019-02-11 17:54:51 +08:00