Skip to content

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

Open
@ToreyStapleton

Description

@ToreyStapleton

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions