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

Tests with many network requests are slower in 6.7+ since logging of all intercepts #18771

Closed
be-hel opened this issue Nov 3, 2021 · 8 comments
Labels
stale no activity on this issue for a long period topic: cy.intercept() type: performance 🏃‍♀️ Performance related

Comments

@be-hel
Copy link

be-hel commented Nov 3, 2021

What would you like?

I would like to exclude some network requests from Cypress since cypress processing is not fast ennough for high performing applications. The response time is so slow that it both can make the tests flaky and also the test execution time is too long. A simple solution would e.g. by adding some config where I can list the requests I want to bypass Cypress processing.

Why is this needed?

As cypress has evolved processing requests have become slower, which is the natural cost of enabling more features in Cypress. See example for various cypress versions below.

Test page:

<!DOCTYPE html><html> <head> <title>Slow Loading</title>
    <script>
        (async() => {
            let startTime = performance.now();
            for (let i = 0; i < 100; i++) {
                    await fetch('webclient/test.jpg');
            }
            const nonParallellResult = performance.now() - startTime;
            document.getElementById('header').innerText = 'Fetching in parallell...';
            startTime = performance.now();
            const createRunner = () => new Promise(async (res, _) => {
                for (let i = 0; i < 100; i++) {
                    await fetch('webclient/test.jpg');
                }
                res();
            });
            const inParallell = 5;
            const runners = [];
            for (let i = 0; i < inParallell; i++) {
                runners.push(createRunner());
            }
            await Promise.all(runners);
            const parallellResult = performance.now() - startTime;
            document.getElementById('header').innerText = `Done, fetch 100 in sequence in ${nonParallellResult} ms and 500 in parallell in ${parallellResult} ms`;
        })();
</script></head>

<body><h1 id='header'>Fetching one at a time...</h1></body>
</html>

The result is the following when loading the test page in various versions of cypress (test.jpg is 415 kB):
8.7.0: Done, fetch 100 in sequence in 1992.800000011921 ms and 500 in parallell in 7448.199999988079 ms
7.6.0: Done, fetch 100 in sequence in 1470.2999999523163 ms and 500 in parallell in 6233.800000011921 ms
7.5.0: Done, fetch 100 in sequence in 1301 ms and 500 in parallell in 4818.800000011921 ms
6.7.0: Done, fetch 100 in sequence in 948.8000000119209 ms and 500 in parallell in 4337.900000035763 ms

Other

This is related to #8156. If that issue is fixed there may be no need for the abilty to exclude requests.

@jennifer-shehane
Copy link
Member

Thanks for providing a reproducible example to track down perf issues. We have some reports of this, but often there isn't a narrowed down version of the issue for us to verify.

@be-hel
Copy link
Author

be-hel commented Nov 3, 2021

Possibly my request is similar to #9358, depending on how that is implemented

@jennifer-shehane
Copy link
Member

Yes, that is planned work for the future, but I think that addressing the performance of logs is something we should look into also. Someone may wish to see 100s of logs and this should be performant as well.

@jennifer-shehane jennifer-shehane changed the title Exclude network requests from cypress processing Tests with many network requests are slower in 6.7+ since logging of all intercepts Nov 5, 2021
@helenaritson
Copy link

We are also experiencing this issue - tests are flaky with long execution time which means we can't upgrade before this issue is solved.

@flotwig flotwig removed their assignment Sep 1, 2022
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Apr 12, 2023

You can now turn off logging for requests by passing log: false through cy.intercept() as shown in this doc. This could help with any performance issues of logging multiple requests.

@mirobo
Copy link
Contributor

mirobo commented Apr 13, 2023

@jennifer-shehane I didn't know that this option would help with performance issues but according to #26069 the log cannot be deactivated if an interceptor function is used. If the performance benefit proves to be measurable, I'd highly appreciate prioritizing the other ticket 😊. I did some measurements on my machine, I even compared it down even to 8.3.1, over 10.7.0 up to 12.8.1 but my testset didn't show any performance issues. My testset was not intercept/request-heavy so I might need to change that and get some real world examples into it.

@nagash77 nagash77 added type: feature New feature that does not currently exist and removed stage: backlog labels Apr 13, 2023
@nagash77 nagash77 added stage: backlog and removed type: feature New feature that does not currently exist labels Apr 13, 2023
@mjhenkes mjhenkes assigned mschile and unassigned mjhenkes Apr 25, 2023
@mschile mschile removed their assignment Apr 25, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Oct 23, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity on this issue for a long period topic: cy.intercept() type: performance 🏃‍♀️ Performance related
Projects
None yet
Development

No branches or pull requests

9 participants