phpSyllable
phpSyllable copied to clipboard
Processing really slow. How to configure cache correctly?
Processing large texts is incredibly slow for me. Calling hyphenateHtml takes 25 seconds and more. Is this reasonable for text with roughly 3100 characters? If so, any idea how I could speed this up?
I should mention that I'm not quite sure that caching is working properly. Although files are successfully created in the directory I configured...
$syllable = new Syllable();
$syllable->getCache()->setPath('/app/syllable_cache');
$syllable->setLanguage('de-1996');
$someText = $syllable->hyphenateHtml($someText);
... it doesn't seem to make a significant difference. With and without cache files, processing time is approximately the same. Is there something else I have to do to activate the cache? How is cache invalidation triggered? My input text doesn't change.
Unless your HTML is especially complicated, performance should be far better for such a short text, even without cache. Have you tried performance without HTML? You can try non-HTML on one of my own websites here: http://syllable.toyls.com/, which does some additional analysis on the text but still manages to do 10k of character in german in about 2 seconds.
Is there any chance you could share the text on something like https://pastebin.com/?
Thanks for the quick reply.
Sure, here is the text.
I checked the character count again (with this) and it tuned out to be much bigger than I initially stated: 359899 characters! No idea why PHPs strlen() only returns 3100.
Closing as original text is no longer available and parsed text appeared to be about a 100x longer than initially reported. Assuming strlen() might have reported less due to multibyte unicode. Use mb_strlen() instead.