forked from jazzband/django-floppyforms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.py
35 lines (27 loc) · 841 Bytes
/
benchmark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Compares the rendering speed between Django forms and django-floppyforms
"""
import timeit
django = """from django import forms
class DjangoForm(forms.Form):
text = forms.CharField()
slug = forms.SlugField()
some_bool = forms.BooleanField()
email = forms.EmailField()
date = forms.DateTimeField()
file_ = forms.FileField()
rendered = DjangoForm().as_p()"""
flop = """import floppyforms as forms
class FloppyForm(forms.Form):
text = forms.CharField()
slug = forms.SlugField()
some_bool = forms.BooleanField()
email = forms.EmailField()
date = forms.DateTimeField()
file_ = forms.FileField()
rendered = FloppyForm().as_p()"""
def time(stmt):
t = timeit.Timer(stmt=stmt)
return t.timeit(number=1000)
print "Plain Django:", time(django)
print "Django-floppyforms:", time(flop)