-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tsearch: add optimize StringSize method
This commit introduces `TSVector.StringSize` method which is optimized equivalent of `len(TSVector.String())` which avoids the construction of the string. This method is now utilized by `DTSVector.Size`. This results in some code duplication but it seems worth it: ``` │ /tmp/tmp.zD8FYqMrdo/bench.HEAD^ │ /tmp/tmp.zD8FYqMrdo/bench.HEAD │ │ sec/op │ sec/op vs base │ TSVector/String-24 8.404m ± 0% 8.135m ± 0% -3.20% (p=0.000 n=10) TSVector/StringSize-24 8.381m ± 0% 3.547m ± 0% -57.67% (p=0.000 n=10) geomean 8.393m 5.372m -35.99% │ /tmp/tmp.zD8FYqMrdo/bench.HEAD^ │ /tmp/tmp.zD8FYqMrdo/bench.HEAD │ │ B/op │ B/op vs base │ TSVector/String-24 2.349Mi ± 0% 2.323Mi ± 0% -1.12% (p=0.000 n=10) TSVector/StringSize-24 2405.6Ki ± 0% 192.1Ki ± 0% -92.02% (p=0.000 n=10) geomean 2.349Mi 675.9Ki -71.90% │ /tmp/tmp.zD8FYqMrdo/bench.HEAD^ │ /tmp/tmp.zD8FYqMrdo/bench.HEAD │ │ allocs/op │ allocs/op vs base │ TSVector/String-24 106.7k ± 0% 105.8k ± 0% -0.88% (p=0.000 n=10) TSVector/StringSize-24 106.72k ± 0% 61.46k ± 0% -42.41% (p=0.000 n=10) geomean 106.7k 80.63k -24.44% ``` Release note: None
- Loading branch information
1 parent
13d99ec
commit 1dcb587
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters