phpSyllable icon indicating copy to clipboard operation
phpSyllable copied to clipboard

Processing really slow. How to configure cache correctly?

Open gruhn opened this issue 7 years ago • 2 comments

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.

gruhn avatar Apr 11 '18 14:04 gruhn

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/?

vanderlee avatar Apr 11 '18 15:04 vanderlee

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.

gruhn avatar Apr 11 '18 15:04 gruhn

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.

vanderlee avatar Apr 20 '23 12:04 vanderlee