Closed stklcode closed 7 years ago
Ran a quick benchmark with several keys (non-listed, listed in front/middle/ent of the array) against a large filter list (4k entries) and a short list (10 entries).
Averages are:
Method avg (4k) avg (20)
in_array() 13.7 µs 1.8 µs
array_key_exists() 1.8 µs 1.8 µs
isset() 1.3 µs 1.3 µs
Ordering has only a small and varying impact <.1µs, not worth confusing the user.
Overall not a big deal on small filter lists, but the results are clear, as checking array keys scales much better. Seems that isset()
is the way to go.
In 1.1.x the filter hook splits referer domain by dot and runs the last 2 parts (sld.tld) against a blacklist using
in_array()
. It's fast, but it can be faster, as the hook is exeuted on every visit.Some evaluation hast to be made to compare different methods in a real-world scenario (about a dozen blacklisted domains with a small percentage of hits).
First improvement in develop branch is the switch from
in_array()
toisset()
by flipping the array.