(This is the sister issue of #2026255: Make CascadingStylesheetsTest 3500% faster.)

While working on #352951: Make JS & CSS Preprocessing Pluggable, I got very much fed up with the extreme slowness of JavaScriptTest.php.

Difference

  • Before: 610 seconds (10 min 10 sec)
  • After: 19 seconds
  • (That's 32.105 times faster, or only 3.11% of the original test running time.)

It used WebTestBase for historical reasons, while it could easily use DrupalUnitTestBase now.

Ideally, this would be a PHPUnit test, but that's not technically possible right now. This will at least make it a whole lot faster, while retaining the same test coverage.

Changes

I changed as little as possible:

  • DrupalWebTestBase -> DrupalUnitTestBase
  • Removed the testing of the presence of drupalSettings.currentPath in the actual rendered HTML; it's already being tested higher up in testHeaderSetting() anyway.
  • Instead of relying on a certain page callback in common_test module, which would indeed need WebTestBase, I just moved the relevant parts of common_test.module into the test itself (2 lines of code).

Comments

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new3.04 KB
wim leers’s picture

Issue tags: +Test suite performance

.

Status: Needs review » Needs work

The last submitted patch, javascripttest_32_times_faster-2026349-1.patch, failed testing.

wim leers’s picture

Status: Needs work » Postponed
StatusFileSize
new2.8 KB

Postponed on #352951: Make JS & CSS Preprocessing Pluggable, this reroll is applied on top of that. So, marking as postponed until that patch gets committed.

wim leers’s picture

Status: Postponed » Needs review

#352951: Make JS & CSS Preprocessing Pluggable got committed, now this should pass tests and get to RTBC.

Status: Needs review » Needs work

The last submitted patch, javascripttest_32_times_faster-2026349-4.patch, failed testing.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new3.39 KB

Status: Needs review » Needs work
Issue tags: -Test suite performance

The last submitted patch, javascripttest_32_times_faster-2026349-7.patch, failed testing.

wim leers’s picture

Status: Needs work » Needs review
Issue tags: +Test suite performance
fubhy’s picture

Difference

Before: 610 seconds (10 min 10 sec)
After: 19 seconds
(That's 32.105 times faster, or only 3.11% of the original test running time.)

Wim, I love you.

nod_’s picture

Looks good to me, what's left for RTBC?

nod_’s picture

Status: Needs review » Reviewed & tested by the community

nothing apparently, the change for the query string is legit, don't need a page to make sure it works. Everything happens before the page is rendered.

pancho’s picture

Awesome improvement, but why is it added to the Pluggable CSS & JS preprocessing change record? Let's instead create a separate change record "Vastly improved performance for many Simpletests" or so. It's no API change, but taken together it's very much noteworthy.

wim leers’s picture

#13: we don't create change records for faster tests. I just referenced it in the pluggable CSS/JS change record because as part of working on that, I also did this. If it bothers you, feel free to remove it from that change record. You're right that it's strictly not functionally related.

amateescu’s picture

I also think that test improvements do not belong to a change record. After all, what's the audience for this.. 20-30 people? And they already know the difference between a web test and a unit test.

@Wim Leers, no offense, but I think you've been around marketing and sales people for too long :P

/me is looking forward to the next "stellar" thing :D

pancho’s picture

Added it to the New DrupalUnitTestBase change record instead

wim leers’s picture

#15: haha :) You're right. I haven't been around a whole lot of marketing or sales people though :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice one... Committed cb7f315 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.