Opened 18 years ago
Closed 18 years ago
#3099 closed enhancement (duplicate)
New faster SelectBox.js
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | graham@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
If you have thousands of entries in a multiple select box in the Django admin interface, the Javascript in SelectBox.js which makes the nice gui widget, runs too slowly, and the browser will complain.
Here is a new SelectBox.js that uses maps/objects where it used to use lists, changing the complexity of SelectBox.move from quadratic to
linear (and I thought big O notation was just for interview questions!). For example on a list of 4000 elements it now iterates 4000 times instead of up to 16 Million (4000*4000).
This also always displays the entries sorted alphabetically. This was, I _think_, the intention of the original SelectBox, but it wasn't happening in practice. Aside from this behaviour is identical to previous SelectBox.
Attachments (2)
Change History (10)
by , 18 years ago
Attachment: | SelectBox.js added |
---|
comment:3 by , 18 years ago
Cc: | added |
---|
comment:4 by , 18 years ago
Has patch: | set |
---|
follow-up: 6 comment:5 by , 18 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Can someone compare #3202 and this and figure out the better one?
comment:6 by , 18 years ago
Replying to SmileyChris:
Can someone compare #3202 and this and figure out the better one?
Performance wise, this patch actually did worse in my testing than the original (I'm attaching a screenshot of the Firebug profiler as evidence). Using an Object rather than Array doesn't seem to speed up anything. Also note how much time the sort method takes compared to the original and #3202. It is much more time here. If this patch is intended to fix a sorting bug, then another patch should be submitted after taking into account the changes in patch #3202.
comment:7 by , 18 years ago
I'm getting an error when trying to upload an attachment. I posted to Django-developers and hopefully it will be fixed soon so I can upload the screenshot of the javascript profiler.
comment:8 by , 18 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
I've done some Firebug profiling as well, and I agree. This version (which I wrote) is actually about a second slower than the original in Firefox. I tested #3202 and it is a good bit faster than the original, so for Firefox my vote goes with that. Apologies for wasting time.
Neither this nor #3202 seem to make any difference to IE though. I'm going to close this and add my comments to #3202 about what we might be able to do about IE.
Closing as duplicate of #3202.
by , 18 years ago
a patch instead of the whole file. also fixed indention and spacing.
Replacement for django/contrib/admin/media/js/SelectBox