amnuts / opcache-gui

A clean, effective and responsive interface for Zend OPcache
1.21k stars 197 forks source link

Slow filter refresh #11

Closed VinWz closed 8 years ago

VinWz commented 8 years ago

Hello Amnuts and thank you for this nice contribution!

I was wondering if there is any good alternative to keyup() in this case.

        $('#frmFilter').bind('keyup', function(event){
            $('span.pathname').each(function(index){
                if ($(this).text().toLowerCase().indexOf($('#frmFilter').val().toLowerCase()) == -1) {
                    $(this).closest('tr').addClass('hide');
                } else {
                    $(this).closest('tr').removeClass('hide');
                }
            });
            $('#filelist table tbody').trigger('paint');
        });

Indeed, while dealing with large amounts of paths, I'd rather it refresh the filtered entries only if both the filter field has changed and there has not been a keyup event for the last second or so. The letter-by-letter refresh is taking a long time (since it freezes the input field) for only about 5k paths on a quite powerful laptop with Chrome.

Best regards!

amnuts commented 8 years ago

Thanks for the feedback, @VinWz. I've been meaning to put a debounce routine on the top of that keyup precisely to stop it firing on every single key press. I'll try to get that done very soon.

VinWz commented 8 years ago

Cool! Thank you very much, @amnuts !

amnuts commented 8 years ago

OK, I think I've made it a fair bit faster now to do the filtering and there's also the debounce so the keyup wont fire until you've finished typing. Changes are up on the branch https://github.com/amnuts/opcache-gui/tree/optimise-filter, so give it a shot and let me know if it helps any. If so, I'll merge it into master.

VinWz commented 8 years ago

Hi again!

Thank you, I've just had the time to test it before one colleague cleared the cache! :-P The debounce increases the usability quite well. :-)

PS : I tuned it up to 300, but it is a personal preference (meaning you also wait a bit more after finishing typing).

Best regards