Admin actions.js performance

83 views
Skip to first unread message

ecas

unread,
Aug 4, 2017, 7:30:24 AM8/4/17
to Django developers (Contributions to Django itself)
Hi,

I was doing some loading time benchmarking in Chrome and I noticed that the javascript that sets up the actions in the admin page takes some time.

I pinpointed the problem to this jquery:

        $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
            list_editable_changed = true;
        });

If I replace it with the following top-down approach, the execution time of the overall function call is reduced from ~115ms to ~53ms (as seen in the attached screenshots)

        $('form#changelist-form table#result_list tr').find('td:gt(0)').find(':input').change(function() {
            list_editable_changed = true;
        });

Has anybody noticed this or can reproduce it?

Thanks!

Screenshot chrome 1.png
Screenshot chrome 2.png

Collin Anderson

unread,
Aug 4, 2017, 9:20:55 AM8/4/17
to django-d...@googlegroups.com
I can confirm it's slightly faster in my case (maybe 20-50ms for 58 rows, 3 inputs per row).

I can get it ~15ms faster by making it just one event handler, though it's a bigger change:
$('#result_list').on('change', 'td:nth-child(n+2) :input', function() {

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/86804109-cd6d-4514-82c1-72b53e000ef2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ecas

unread,
Aug 7, 2017, 4:19:16 AM8/7/17
to Django developers (Contributions to Django itself)
Is there any way to propose this optimization to be considered? I have never posted code to the Django community.

El divendres, 4 agost de 2017 15:20:55 UTC+2, Collin Anderson va escriure:
I can confirm it's slightly faster in my case (maybe 20-50ms for 58 rows, 3 inputs per row).

I can get it ~15ms faster by making it just one event handler, though it's a bigger change:
$('#result_list').on('change', 'td:nth-child(n+2) :input', function() {
On Fri, Aug 4, 2017 at 7:29 AM, ecas <eloi....@gmail.com> wrote:
Hi,

I was doing some loading time benchmarking in Chrome and I noticed that the javascript that sets up the actions in the admin page takes some time.

I pinpointed the problem to this jquery:

        $('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
            list_editable_changed = true;
        });

If I replace it with the following top-down approach, the execution time of the overall function call is reduced from ~115ms to ~53ms (as seen in the attached screenshots)

        $('form#changelist-form table#result_list tr').find('td:gt(0)').find(':input').change(function() {
            list_editable_changed = true;
        });

Has anybody noticed this or can reproduce it?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.

Adam Johnson

unread,
Aug 7, 2017, 7:39:30 AM8/7/17
to django-d...@googlegroups.com
I've made a ticket here: https://code.djangoproject.com/ticket/28472#ticket . You can follow https://docs.djangoproject.com/en/dev/intro/contributing/ to make a Pull Request on GitHub against this ticket 👌

To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam
Reply all
Reply to author
Forward
0 new messages