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

Performance Issues, ~6x longer to render than regular django forms #62

Open
troygrosfield opened this issue Aug 13, 2014 · 0 comments
Open

Comments

@troygrosfield
Copy link

Here's the script that was used for the test:

from datetime import datetime

from bootstrapform.templatetags.bootstrap import bootstrap
from django import forms


class SomeTestForm(forms.Form):
    field_1 = forms.CharField(max_length=20)
    field_2 = forms.CharField(max_length=20)
    field_3 = forms.CharField(max_length=20)
    field_4 = forms.CharField(max_length=20)
    field_5 = forms.CharField(max_length=20)


def create_form():
    initial = {
        'field_1': 'Some random string 1.',
        'field_2': 'Some random string 2.',
        'field_3': 'Some random string 3.',
        'field_4': 'Some random string 4.',
        'field_5': 'Some random string 5.'
    }
    return SomeTestForm(initial=initial)

# Test rendering 1000 forms
forms = [create_form() for f in range(1000)]

# render using django form render
start_time_django_rendering = datetime.utcnow()

for form in forms:
    form.as_table()

end_time_django_rendering = datetime.utcnow()
total_django_rendering_time = (end_time_django_rendering - start_time_django_rendering)

print('Total django rendering time: {0}'.format(total_django_rendering_time))

# render using bootstrap form renderer
start_time_bootstrap = datetime.utcnow()

for form in forms:
    bootstrap(form)

end_time_bootstrap = datetime.utcnow()
total_bootstrap_time = end_time_bootstrap - start_time_bootstrap

print('Total bootstrap rendering time: {0}'.format(total_bootstrap_time))

Result test runs:
Run 1:

Total django rendering time:    0:00:01.293791
Total bootstrap rendering time: 0:00:06.579422

Run 2:

Total django rendering time:    0:00:01.298067
Total bootstrap rendering time: 0:00:06.548636

Run 3:

Total django rendering time:    0:00:01.304047
Total bootstrap rendering time: 0:00:06.530172

Run 4:

Total django rendering time:    0:00:01.293400
Total bootstrap rendering time: 0:00:06.584375

Run 5:

Total django rendering time:    0:00:01.294149
Total bootstrap rendering time: 0:00:06.550580
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

1 participant