Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the js package test by using compatibility mode base #1426

Closed
mstoykov opened this issue Apr 30, 2020 · 1 comment
Closed

Optimize the js package test by using compatibility mode base #1426

mstoykov opened this issue Apr 30, 2020 · 1 comment

Comments

@mstoykov
Copy link
Contributor

For the most part most test execute extremely simple 1-2 line scripts which can be rewritten to not require babel or corejs and at this point run in compatibility-mode=base.

This shouldn't really be a problem for finding bugs in the extended mode, but maybe I am wrong.
As an example, I give TestVURunInterruptDoesntPanic, which is probably not the most representative, but still. The below are the first and second run of the same test (using -count):
without specifying compatibility-mode:base:

--- PASS: TestVURunInterruptDoesntPanic (13.89s)
    --- PASS: TestVURunInterruptDoesntPanic/Source (1.97s)
    --- PASS: TestVURunInterruptDoesntPanic/Archive (2.00s)
=== RUN   TestVURunInterruptDoesntPanic
=== RUN   TestVURunInterruptDoesntPanic/Source
=== RUN   TestVURunInterruptDoesntPanic/Archive
--- PASS: TestVURunInterruptDoesntPanic (4.93s)
    --- PASS: TestVURunInterruptDoesntPanic/Source (1.99s)
    --- PASS: TestVURunInterruptDoesntPanic/Archive (1.95s)

after speciying:

=== RUN   TestVURunInterruptDoesntPanic
=== RUN   TestVURunInterruptDoesntPanic/Source
=== RUN   TestVURunInterruptDoesntPanic/Archive
--- PASS: TestVURunInterruptDoesntPanic (3.48s)
    --- PASS: TestVURunInterruptDoesntPanic/Source (1.72s)
    --- PASS: TestVURunInterruptDoesntPanic/Archive (1.76s)
=== RUN   TestVURunInterruptDoesntPanic
=== RUN   TestVURunInterruptDoesntPanic/Source
=== RUN   TestVURunInterruptDoesntPanic/Archive
--- PASS: TestVURunInterruptDoesntPanic (3.55s)
    --- PASS: TestVURunInterruptDoesntPanic/Source (1.75s)
    --- PASS: TestVURunInterruptDoesntPanic/Archive (1.79s)

as you can see the difference is signifacant as the parsing of the code apperantly takes 10.5s more without specifying base and the execution combined takes like 0.5s less (the number vary but not more then 0.1s in my experiments).

All of the above is ran with -race and the code change is:

diff --git a/js/runner_test.go b/js/runner_test.go
index 15d24d1d..350db362 100644
--- a/js/runner_test.go
+++ b/js/runner_test.go
@@ -584,13 +584,15 @@ func TestVURunInterruptDoesntPanic(t *testing.T) {
                t.Skip()
        }

-       r1, err := getSimpleRunner("/script.js", `
-               export default function() { while(true) {} }
-               `)
+       rtOpts := lib.RuntimeOptions{CompatibilityMode: null.StringFrom("base")}
+       r1, err := getSimpleRunnerWithOptions("/script.js", `
+               exports.default = function() { while(true) {} }
+               `, rtOpts)
+
        require.NoError(t, err)
        require.NoError(t, r1.SetOptions(lib.Options{Throw: null.BoolFrom(true)}))

-       r2, err := NewFromArchive(r1.MakeArchive(), lib.RuntimeOptions{})
+       r2, err := NewFromArchive(r1.MakeArchive(), rtOpts)
        require.NoError(t, err)
        testdata := map[string]*Runner{"Source": r1, "Archive": r2}
        for name, r := range testdata {
@mstoykov
Copy link
Contributor Author

This was done by #1429

@mstoykov mstoykov added this to the v0.27.0 milestone Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants