diff --git a/README.md b/README.md index 67e0a5d..3349d8c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Performance This solution is partially optimized for multi-threading. +It is also somewhat optimized for likely intended phrases, as anagrams consisting of longer words are generated first. + Single-threaded performance on Sandy Bridge @2.8GHz is as follows: * If only phrases of at most 3 words are allowed, then it takes 2.5 seconds to find and check all anagrams; all relevant hashes are solved in first 0.4 seconds; @@ -29,4 +31,4 @@ Multi-threaded performance is as follows: * If only phrases of at most 4 words are allowed, then it takes 20 seconds to find and check all anagrams; all hashes are solved in first 1.5 seconds -* If phrases of 5 words are allowed as well, then all hashes are solved in first 29 seconds. Around 50% of time is spent on MD5 computations for correct anagrams, so there is not a lot to optimize further. +* If phrases of 5 words are allowed as well, then it takes around half an hour to find and check all anagrams; all hashes are solved in first 25 seconds. Around 50% of time is spent on MD5 computations for correct anagrams, so there is not a lot to optimize further. diff --git a/WhiteRabbit/VectorsProcessor.cs b/WhiteRabbit/VectorsProcessor.cs index c4d75de..f7f738b 100644 --- a/WhiteRabbit/VectorsProcessor.cs +++ b/WhiteRabbit/VectorsProcessor.cs @@ -47,6 +47,7 @@ // We want words with more letters (and among these, words with more "rare" letters) to appear first, to reduce the searching time somewhat. // Applying such a sort, we reduce the total number of triplets to check for anagrams from ~62M to ~29M. // Total number of quadruplets is reduced from 1468M to mere 311M. + // And total number of quintuplets becomes reasonable 1412M. // Also, it produces the intended results faster (as these are more likely to contain longer words - e.g. "poultry outwits ants" is more likely than "p o u l t r y o u t w i t s a n t s"). // This method basically gives us the 1-norm of the vector in the space rescaled so that the target is [1, 1, ..., 1]. private int GetVectorWeight(Vector vector)