Lazy loaded (and evictable) dictionaries clobbers test suite performance
After upgrading to 1.0.0 our rspec test suite completion time has increased from ~4m20s to ~6m30s.
We expect this is due to lazy loading the dictionaries. Is there a way to eager load them for the test suite?
Hello @hyodyllinentekniikka ,
I had the same issue initially, this was expected, though, as dictionaries now can be removed from memory after use. You could keep the dictionaries in memory using the strategy delineated at https://github.com/formigarafa/zxcvbn-rb?tab=readme-ov-file#testing-multiple-passwords.
To just get the old behaviour you can just replace the usages of zxcvbn with that strategy.
To get a different behaviour on test mode only you may need to implement some sort of test mode to keep the dictionaries loaded in memory.
A quick way to do it would be to have this piece of code loaded before your tests run:
module Zxcvbn
def self.tester
@tester ||= Zxcvbn::Tester.new
end
def self.zxcvbn(*)
tester.zxcvbn(*)
end
def self.test(password, user_inputs = [])
tester.test(password, user_inputs)
end
end