mozilla-l10n/langchecker

Stop using global variables, add tests

flodolo opened this issue · 5 comments

Currently working on a rewrite of the code that:

  • Doesn't rely on global variables to store strings and data
  • Use classes consistently instead of importing functions from /lib
  • Have tests

I've already rewritten the main parser class, now I'm going through each view, moving functions in a class and adding tests.

WIP here https://github.com/flodolo/langchecker/commits/class_rewrite

This branch is built on top of code from #135: the idea is to not add new features in the rewrite, just replicate what langchecker currently does.

Ported all views to new classes and functions, still missing lang_update. Next week I should have something usable.

Numbers look promising. Patched template to display memory usage, numbers retrieved with this script

Average on 10 tries

/?locale=it
before: 0.33657 seconds, 3.00 MB
after: 0.18560 seconds, 2.25 MB

/?action=activation
before: 3.35267 seconds, 3.25 MB
after: 0.771740 seconds, 2.00 MB

/?action=errors
before: 16.89741 seconds, 5.00 MB
after: 9.26195 seconds, 2.50 MB

Some other heavy pages

?website=0&file=main.lang&action=translate
before: 7.03488 seconds, 5.50 MB
after: 0.12375 seconds, 4.00 MB

?base_langchecker + "?website=0&file=main.lang&locale=all
before: 0.24163 seconds, 2.50 MB
after: 0.159310 seconds, 1.75 MB

?action=count
before: 8.93577 seconds, 5.00 MB
after: 2.05418 seconds, 2.00 MB

Noting some issues that I found in the current version, and will be fixed in the rewrite.

  • Original string 01, translation 1, string is considered identical because we're doing loose comparisons in analyseLangFile.
  • Even if we set a file to critical in sources.php, it won't be marked as critical in the dashboard unless we update views/export. In the rewrite the array with priorities is associated directly to the website array.

Fixed by #140