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

Faster clear by running .textContent = "" after a rAF #166

Closed
adamhaile opened this issue Apr 22, 2017 · 2 comments
Closed

Faster clear by running .textContent = "" after a rAF #166

adamhaile opened this issue Apr 22, 2017 · 2 comments

Comments

@adamhaile
Copy link
Contributor

Discovered this one from vidom's fast "clear rows" result and thought I'd pass it on.

If you run .textContent = "" after a requestAnimantionFrame, it saves 35-40ms in the "clear rows" benchmark.

So tweaked vanillajs-keyed Main.clear() looks like:

    clear() {
        startMeasure("clear");
        this.store.clear();
        this.rows = [];
        this.data = [];
        var that = this;
        requestAnimationFrame(function () {
            that.removeAllRows();
            this.unselect();
        });
        stopMeasure();
    }

Same trick saves about 5ms in the "replace all rows" test.

krausest added a commit that referenced this issue Apr 22, 2017
@krausest
Copy link
Owner

Thanks - very interesting. I implemented it only for clear all rows where it improved the benchmark significantly.
As for replace all rows I decided not to implement it, since I've seen the 5 mecs improvement you described but about half of the time it performed worse (maybe a case of bad timing when it almost had to wait almost 17 msecs for the next frame).

@krausest
Copy link
Owner

Updates results here

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

2 participants