Skip to content

Instantly share code, notes, and snippets.

@orian
Last active September 27, 2020 14:54
Show Gist options
  • Save orian/ab06b8c77e2f86f283772494e945b86e to your computer and use it in GitHub Desktop.
Save orian/ab06b8c77e2f86f283772494e945b86e to your computer and use it in GitHub Desktop.

Old levenstein:

/tmp/___gobench_github_com_datainq_teryt_search -test.v -test.bench . -test.run ^$
goos: linux
goarch: amd64
pkg: github.com/datainq/teryt/search
BenchmarkSearch_SearchOld
BenchmarkSearch_SearchOld-8   	      31	  40371148 ns/op
BenchmarkSearch_Search
BenchmarkSearch_Search-8      	      78	  14253494 ns/op
BenchmarkSearch_SearchV3
BenchmarkSearch_SearchV3/parallel-1
BenchmarkSearch_SearchV3/parallel-1-8         	      73	  14454698 ns/op
BenchmarkSearch_SearchV3/parallel-2
BenchmarkSearch_SearchV3/parallel-2-8         	     148	   7944333 ns/op
BenchmarkSearch_SearchV3/parallel-3
BenchmarkSearch_SearchV3/parallel-3-8         	     192	   6439412 ns/op
BenchmarkSearch_SearchV3/parallel-4
BenchmarkSearch_SearchV3/parallel-4-8         	     210	   5695166 ns/op
BenchmarkSearch_SearchV3/parallel-5
BenchmarkSearch_SearchV3/parallel-5-8         	     234	   5158373 ns/op
BenchmarkSearch_SearchV3/parallel-6
BenchmarkSearch_SearchV3/parallel-6-8         	     259	   4601875 ns/op
BenchmarkSearch_SearchV3/parallel-7
BenchmarkSearch_SearchV3/parallel-7-8         	     274	   4220992 ns/op
BenchmarkSearch_SearchV3/parallel-8
BenchmarkSearch_SearchV3/parallel-8-8         	     290	   4102362 ns/op
PASS

new levenstein:

/tmp/___gobench_github_com_datainq_teryt_search -test.v -test.bench . -test.run ^$
goos: linux
goarch: amd64
pkg: github.com/datainq/teryt/search
BenchmarkSearch_SearchOld
BenchmarkSearch_SearchOld-8   	      32	  40022095 ns/op
BenchmarkSearch_Search
BenchmarkSearch_Search-8      	      84	  13157961 ns/op
BenchmarkSearch_SearchV3
BenchmarkSearch_SearchV3/parallel-1
BenchmarkSearch_SearchV3/parallel-1-8         	      84	  13091772 ns/op
BenchmarkSearch_SearchV3/parallel-2
BenchmarkSearch_SearchV3/parallel-2-8         	     158	   7431540 ns/op
BenchmarkSearch_SearchV3/parallel-3
BenchmarkSearch_SearchV3/parallel-3-8         	     200	   6100214 ns/op
BenchmarkSearch_SearchV3/parallel-4
BenchmarkSearch_SearchV3/parallel-4-8         	     218	   5410983 ns/op
BenchmarkSearch_SearchV3/parallel-5
BenchmarkSearch_SearchV3/parallel-5-8         	     246	   4947954 ns/op
BenchmarkSearch_SearchV3/parallel-6
BenchmarkSearch_SearchV3/parallel-6-8         	     272	   4372559 ns/op
BenchmarkSearch_SearchV3/parallel-7
BenchmarkSearch_SearchV3/parallel-7-8         	     308	   3969459 ns/op
BenchmarkSearch_SearchV3/parallel-8
BenchmarkSearch_SearchV3/parallel-8-8         	     320	   3739096 ns/op
PASS

the newest levenstein

go test -test.v -test.bench ^BenchmarkSearch_Search.*$ -test.run ^$
goos: linux
goarch: amd64
pkg: github.com/datainq/teryt/search
BenchmarkSearch_SearchOld
BenchmarkSearch_SearchOld-8   	      37	  33642952 ns/op
BenchmarkSearch_Search
BenchmarkSearch_Search-8      	     152	   7784588 ns/op
BenchmarkSearch_SearchV3
BenchmarkSearch_SearchV3/parallel-1
BenchmarkSearch_SearchV3/parallel-1-8         	     150	   7900379 ns/op
BenchmarkSearch_SearchV3/parallel-2
BenchmarkSearch_SearchV3/parallel-2-8         	     277	   4286875 ns/op
BenchmarkSearch_SearchV3/parallel-3
BenchmarkSearch_SearchV3/parallel-3-8         	     321	   3643391 ns/op
BenchmarkSearch_SearchV3/parallel-4
BenchmarkSearch_SearchV3/parallel-4-8         	     330	   3492188 ns/op
BenchmarkSearch_SearchV3/parallel-5
BenchmarkSearch_SearchV3/parallel-5-8         	     382	   3085371 ns/op
BenchmarkSearch_SearchV3/parallel-6
BenchmarkSearch_SearchV3/parallel-6-8         	     429	   2752282 ns/op
BenchmarkSearch_SearchV3/parallel-7
BenchmarkSearch_SearchV3/parallel-7-8         	     493	   2352805 ns/op
BenchmarkSearch_SearchV3/parallel-8
BenchmarkSearch_SearchV3/parallel-8-8         	     490	   2433284 ns/op
PASS
ok  	github.com/datainq/teryt/search	27.525s

adding some microoptimizatins:

go test -test.v -test.bench ^BenchmarkSearch_SearchV3$ -test.run ^$ -benchtime=5s
goos: linux
goarch: amd64
pkg: github.com/datainq/teryt/search
BenchmarkSearch_SearchV3
BenchmarkSearch_SearchV3/parallel-1
BenchmarkSearch_SearchV3/parallel-1-8         	     754	   7874687 ns/op	  923262 B/op	   57259 allocs/op
BenchmarkSearch_SearchV3/parallel-2
BenchmarkSearch_SearchV3/parallel-2-8         	    1400	   4333108 ns/op	  923608 B/op	   57265 allocs/op
BenchmarkSearch_SearchV3/parallel-3
BenchmarkSearch_SearchV3/parallel-3-8         	    1704	   3240396 ns/op	  924026 B/op	   57271 allocs/op
BenchmarkSearch_SearchV3/parallel-4
BenchmarkSearch_SearchV3/parallel-4-8         	    2059	   2845054 ns/op	  924319 B/op	   57277 allocs/op
BenchmarkSearch_SearchV3/parallel-5
BenchmarkSearch_SearchV3/parallel-5-8         	    1951	   2994834 ns/op	  924444 B/op	   57283 allocs/op
BenchmarkSearch_SearchV3/parallel-6
BenchmarkSearch_SearchV3/parallel-6-8         	    2253	   2618783 ns/op	  925045 B/op	   57289 allocs/op
BenchmarkSearch_SearchV3/parallel-7
BenchmarkSearch_SearchV3/parallel-7-8         	    2524	   2325082 ns/op	  925224 B/op	   57295 allocs/op
BenchmarkSearch_SearchV3/parallel-8
BenchmarkSearch_SearchV3/parallel-8-8         	    2718	   2170452 ns/op	  925588 B/op	   57301 allocs/op
PASS
ok  	github.com/datainq/teryt/search	63.756s

reuse levenstein computation buffer between runs:

go test -test.v -test.bench ^BenchmarkSearch_SearchV3$ -test.run ^$ -benchtime=5s
goos: linux
goarch: amd64
pkg: github.com/datainq/teryt/search
BenchmarkSearch_SearchV3
BenchmarkSearch_SearchV3/parallel-1
BenchmarkSearch_SearchV3/parallel-1-8         	     909	   6590511 ns/op	     690 B/op	      22 allocs/op
BenchmarkSearch_SearchV3/parallel-2
BenchmarkSearch_SearchV3/parallel-2-8         	    1728	   3420206 ns/op	    1052 B/op	      28 allocs/op
BenchmarkSearch_SearchV3/parallel-3
BenchmarkSearch_SearchV3/parallel-3-8         	    2329	   2384354 ns/op	    1419 B/op	      34 allocs/op
BenchmarkSearch_SearchV3/parallel-4
BenchmarkSearch_SearchV3/parallel-4-8         	    3158	   1943018 ns/op	    1775 B/op	      40 allocs/op
BenchmarkSearch_SearchV3/parallel-5
BenchmarkSearch_SearchV3/parallel-5-8         	    2184	   2400980 ns/op	    2159 B/op	      46 allocs/op
BenchmarkSearch_SearchV3/parallel-6
BenchmarkSearch_SearchV3/parallel-6-8         	    2682	   2082410 ns/op	    2493 B/op	      52 allocs/op
BenchmarkSearch_SearchV3/parallel-7
BenchmarkSearch_SearchV3/parallel-7-8         	    3130	   1813368 ns/op	    2868 B/op	      58 allocs/op
BenchmarkSearch_SearchV3/parallel-8
BenchmarkSearch_SearchV3/parallel-8-8         	    3339	   1680302 ns/op	    3212 B/op	      64 allocs/op
PASS
ok  	github.com/datainq/teryt/search	56.517s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment