aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/binary_module_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-17 17:39:15 +0100
committerBjörn Gustavsson <[email protected]>2015-03-26 15:10:57 +0100
commit7946183da3e1cb7ff709030e2ec5ad7f7effdcf4 (patch)
treecbf0db65338bd3d1050e62a73117af47c8cf5f8e /lib/stdlib/test/binary_module_SUITE.erl
parentbffb6ccf3fdd9de98e9ff94e19e8938a2fdc3d57 (diff)
downloadotp-7946183da3e1cb7ff709030e2ec5ad7f7effdcf4.tar.gz
otp-7946183da3e1cb7ff709030e2ec5ad7f7effdcf4.tar.bz2
otp-7946183da3e1cb7ff709030e2ec5ad7f7effdcf4.zip
Optimize binary_module:random_ref_comp/1
The most expensive part of random_ref_comp/1 is do_matches_loop_comp/4. The running time was reduced from roughly 80 seconds to roughly 40 seconds on my computer when I modified the caller to pre-compile the pattern.
Diffstat (limited to 'lib/stdlib/test/binary_module_SUITE.erl')
-rw-r--r--lib/stdlib/test/binary_module_SUITE.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/stdlib/test/binary_module_SUITE.erl b/lib/stdlib/test/binary_module_SUITE.erl
index f828c70b63..77986605a2 100644
--- a/lib/stdlib/test/binary_module_SUITE.erl
+++ b/lib/stdlib/test/binary_module_SUITE.erl
@@ -1130,7 +1130,9 @@ do_random_matches_comp3(N,NeedleRange,HaystackRange) ->
Needles = [random_substring(NeedleRange,Haystack) ||
_ <- lists:duplicate(NumNeedles,a)],
RefRes = binref:matches(Haystack,Needles),
- true = do_matches_comp_loop(10000,Needles,Haystack, RefRes),
+ RefRes = binary:matches(Haystack,Needles),
+ Compiled = binary:compile_pattern(Needles),
+ true = do_matches_comp_loop(10000,Compiled,Haystack, RefRes),
do_random_matches_comp3(N-1,NeedleRange,HaystackRange).
do_matches_comp_loop(0,_,_,_) ->