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

Optimize match length count function #95

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@martint
Member

martint commented Nov 2, 2018

Using a counted loop improves performance, especially for long matches

Benchmark (matchLength)  (padding)  Mode  Cnt   Score   Error  Units
before                1          0  avgt   30   4.452 ± 0.074  ns/op
after                 1          0  avgt   30   4.450 ± 0.292  ns/op

before                1          1  avgt   30   4.438 ± 0.069  ns/op
after                 1          1  avgt   30   4.178 ± 0.097  ns/op

before                1          3  avgt   30   4.600 ± 0.111  ns/op
after                 1          3  avgt   30   4.231 ± 0.162  ns/op

before                1          7  avgt   30   4.276 ± 0.089  ns/op
after                 1          7  avgt   30   3.863 ± 0.065  ns/op

before                1         50  avgt   30   4.302 ± 0.093  ns/op
after                 1         50  avgt   30   3.867 ± 0.059  ns/op

before                3          0  avgt   30   4.745 ± 0.025  ns/op
after                 3          0  avgt   30   4.198 ± 0.103  ns/op

before                3          1  avgt   30   4.784 ± 0.058  ns/op
after                 3          1  avgt   30   4.176 ± 0.070  ns/op

before                3          3  avgt   30   4.807 ± 0.133  ns/op
after                 3          3  avgt   30   4.165 ± 0.091  ns/op

before                3          7  avgt   30   4.311 ± 0.132  ns/op
after                 3          7  avgt   30   3.821 ± 0.029  ns/op

before                3         50  avgt   30   4.289 ± 0.099  ns/op
after                 3         50  avgt   30   3.831 ± 0.085  ns/op

before                7          0  avgt   30   4.232 ± 0.038  ns/op
after                 7          0  avgt   30   3.908 ± 0.121  ns/op

before                7          1  avgt   30   4.210 ± 0.043  ns/op
after                 7          1  avgt   30   3.924 ± 0.085  ns/op

before                7          3  avgt   30   4.179 ± 0.123  ns/op
after                 7          3  avgt   30   3.845 ± 0.085  ns/op

before                7          7  avgt   30   4.226 ± 0.114  ns/op
after                 7          7  avgt   30   3.803 ± 0.031  ns/op

before                7         50  avgt   30   4.271 ± 0.129  ns/op
after                 7         50  avgt   30   3.842 ± 0.085  ns/op

before               15          0  avgt   30   4.848 ± 0.095  ns/op
after                15          0  avgt   30   4.397 ± 0.111  ns/op

before               15          1  avgt   30   4.813 ± 0.045  ns/op
after                15          1  avgt   30   4.384 ± 0.087  ns/op

before               15          3  avgt   30   4.835 ± 0.096  ns/op
after                15          3  avgt   30   4.422 ± 0.116  ns/op

before               15          7  avgt   30   4.863 ± 0.075  ns/op
after                15          7  avgt   30   4.413 ± 0.046  ns/op

before               15         50  avgt   30   4.917 ± 0.143  ns/op
after                15         50  avgt   30   4.364 ± 0.044  ns/op

before              127          0  avgt   30  14.394 ± 0.320  ns/op
after               127          0  avgt   30  11.832 ± 0.396  ns/op

before              127          1  avgt   30  14.352 ± 0.273  ns/op
after               127          1  avgt   30  11.543 ± 0.275  ns/op

before              127          3  avgt   30  14.290 ± 0.142  ns/op
after               127          3  avgt   30  11.709 ± 0.293  ns/op

before              127          7  avgt   30  15.361 ± 2.277  ns/op
after               127          7  avgt   30  11.657 ± 0.296  ns/op

before              127         50  avgt   30  14.121 ± 0.301  ns/op
after               127         50  avgt   30  10.911 ± 0.450  ns/op

before              511          0  avgt   30  47.233 ± 0.905  ns/op
after               511          0  avgt   30  31.330 ± 2.087  ns/op

before              511          1  avgt   30  47.137 ± 0.529  ns/op
after               511          1  avgt   30  30.074 ± 1.008  ns/op

before              511          3  avgt   30  47.017 ± 0.474  ns/op
after               511          3  avgt   30  30.523 ± 1.856  ns/op

before              511          7  avgt   30  46.510 ± 0.441  ns/op
after               511          7  avgt   30  31.102 ± 4.902  ns/op

before              511         50  avgt   30  46.789 ± 1.311  ns/op
after               511         50  avgt   30  27.405 ± 0.225  ns/op
Optimize match length count function
Using a counted loop improves performance, especially for long matches

Benchmark (matchLength)  (padding)  Mode  Cnt   Score   Error  Units
before                1          0  avgt   30   4.452 ± 0.074  ns/op
after                 1          0  avgt   30   4.450 ± 0.292  ns/op

before                1          1  avgt   30   4.438 ± 0.069  ns/op
after                 1          1  avgt   30   4.178 ± 0.097  ns/op

before                1          3  avgt   30   4.600 ± 0.111  ns/op
after                 1          3  avgt   30   4.231 ± 0.162  ns/op

before                1          7  avgt   30   4.276 ± 0.089  ns/op
after                 1          7  avgt   30   3.863 ± 0.065  ns/op

before                1         50  avgt   30   4.302 ± 0.093  ns/op
after                 1         50  avgt   30   3.867 ± 0.059  ns/op

before                3          0  avgt   30   4.745 ± 0.025  ns/op
after                 3          0  avgt   30   4.198 ± 0.103  ns/op

before                3          1  avgt   30   4.784 ± 0.058  ns/op
after                 3          1  avgt   30   4.176 ± 0.070  ns/op

before                3          3  avgt   30   4.807 ± 0.133  ns/op
after                 3          3  avgt   30   4.165 ± 0.091  ns/op

before                3          7  avgt   30   4.311 ± 0.132  ns/op
after                 3          7  avgt   30   3.821 ± 0.029  ns/op

before                3         50  avgt   30   4.289 ± 0.099  ns/op
after                 3         50  avgt   30   3.831 ± 0.085  ns/op

before                7          0  avgt   30   4.232 ± 0.038  ns/op
after                 7          0  avgt   30   3.908 ± 0.121  ns/op

before                7          1  avgt   30   4.210 ± 0.043  ns/op
after                 7          1  avgt   30   3.924 ± 0.085  ns/op

before                7          3  avgt   30   4.179 ± 0.123  ns/op
after                 7          3  avgt   30   3.845 ± 0.085  ns/op

before                7          7  avgt   30   4.226 ± 0.114  ns/op
after                 7          7  avgt   30   3.803 ± 0.031  ns/op

before                7         50  avgt   30   4.271 ± 0.129  ns/op
after                 7         50  avgt   30   3.842 ± 0.085  ns/op

before               15          0  avgt   30   4.848 ± 0.095  ns/op
after                15          0  avgt   30   4.397 ± 0.111  ns/op

before               15          1  avgt   30   4.813 ± 0.045  ns/op
after                15          1  avgt   30   4.384 ± 0.087  ns/op

before               15          3  avgt   30   4.835 ± 0.096  ns/op
after                15          3  avgt   30   4.422 ± 0.116  ns/op

before               15          7  avgt   30   4.863 ± 0.075  ns/op
after                15          7  avgt   30   4.413 ± 0.046  ns/op

before               15         50  avgt   30   4.917 ± 0.143  ns/op
after                15         50  avgt   30   4.364 ± 0.044  ns/op

before              127          0  avgt   30  14.394 ± 0.320  ns/op
after               127          0  avgt   30  11.832 ± 0.396  ns/op

before              127          1  avgt   30  14.352 ± 0.273  ns/op
after               127          1  avgt   30  11.543 ± 0.275  ns/op

before              127          3  avgt   30  14.290 ± 0.142  ns/op
after               127          3  avgt   30  11.709 ± 0.293  ns/op

before              127          7  avgt   30  15.361 ± 2.277  ns/op
after               127          7  avgt   30  11.657 ± 0.296  ns/op

before              127         50  avgt   30  14.121 ± 0.301  ns/op
after               127         50  avgt   30  10.911 ± 0.450  ns/op

before              511          0  avgt   30  47.233 ± 0.905  ns/op
after               511          0  avgt   30  31.330 ± 2.087  ns/op

before              511          1  avgt   30  47.137 ± 0.529  ns/op
after               511          1  avgt   30  30.074 ± 1.008  ns/op

before              511          3  avgt   30  47.017 ± 0.474  ns/op
after               511          3  avgt   30  30.523 ± 1.856  ns/op

before              511          7  avgt   30  46.510 ± 0.441  ns/op
after               511          7  avgt   30  31.102 ± 4.902  ns/op

before              511         50  avgt   30  46.789 ± 1.311  ns/op
after               511         50  avgt   30  27.405 ± 0.225  ns/op

@martint martint force-pushed the martint:count branch from 2116325 to 77667d1 Nov 2, 2018

@dain

dain approved these changes Nov 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment