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

How do you restart or clear the stat collection? #32

Open
ToreyStapleton opened this issue Jul 29, 2016 · 3 comments
Open

How do you restart or clear the stat collection? #32

ToreyStapleton opened this issue Jul 29, 2016 · 3 comments

Comments

@ToreyStapleton
Copy link

ToreyStapleton commented Jul 29, 2016

I am trying to use your package for simple performance tests with Protractor. The issue I have is I have one spec with 3 tests that navigates to 3 different pages, I am calling perfRunner.start() and .stop() in each of these it blocks. However, every time I call for getStats('loadTime'), it returns the same value for each page which is impossible. How do I reset the perfRunner so I get a new loadTime every time?

Consider the following script:

it('logs in', function () {
    perfRunner.start();

    element(by.model('username')).sendKeys(browser.params.login.username);
    element(by.model('password')).sendKeys(browser.params.login.password);
    element(by.css('button[type="submit"]')).click().then(function () {
        Util.waitForUrlChange(/portfolio/).then(function () {
            perfRunner.stop();

            if (perfRunner.isEnabled) {

                perfRunner.getStats('Javascript').then(function (val) {
                    console.log('Javascript: ' + val);
                });

                perfRunner.getStats('loadTime').then(function (val) {
                    console.log('loadTime: ' + val);
                });

                expect(perfRunner.getStats('loadTime')).toBeLessThan(3000);
                expect(perfRunner.getStats('Javascript')).toBeLessThan(1000);
            });
        };
    });
});

it('goes to overview page', function () {
    perfRunner.start();

    var link = $('a[translate="HEADER.NAV_OVERVIEW"]');
    link.click().then(function () {
        Util.waitForUrlChange(/overview/).then(function () {
            perfRunner.stop();
            if (perfRunner.isEnabled) {

                perfRunner.getStats('Javascript').then(function (val) {
                    console.log('Javascript: ' + val);
                });

                perfRunner.getStats('loadTime').then(function (val) {
                    console.log('loadTime: ' + val);
                });

                expect(perfRunner.getStats('loadTime')).toBeLessThan(3000);
                expect(perfRunner.getStats('Javascript')).toBeLessThan(1000);
            });
        });
    });
});`

I have a console for Javascript and loadTime in each it block and this is what it prints:

✓ logs in
Javascript: 399.71500009298325
Load time: 2171

✓ goes to overview page
Javascript: 1282.9210000038147
Load time: 2171

If I called perfRunner.stop(), why is my JavaScript counter incrementing while the loadTime remains the exact same? I want individual results for each it block, not aggregated values.

How do I reset or clear the perfRunner results? Where is the document that lists all the function options, other than perfRunner.start() and perfRunner.stop()? Is there anything like perfRunner.reset() or .clear() etc?

@linwenting
Copy link

I also see the same thing with loadTime. It never reset.

@brianmisle
Copy link

I'm also having the same issue.

@cmrock
Copy link

cmrock commented Dec 18, 2017

dirty fix:
browser refresh does the work to be done.
add browser.refresh() before perfRunner.start();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants