-
Notifications
You must be signed in to change notification settings - Fork 4
Benchmark
Yohan Boniface edited this page Nov 24, 2017
·
2 revisions
import timeit
from biscuits import parse, Cookie
timeit.timeit("parse('simple=value')", number=1000000, globals=globals())
timeit.timeit("""parse('simple="with%20encoded"')""", number=1000000, globals=globals())
timeit.timeit("parse('a=b; foo=bar; bar=baz;')", number=1000000, globals=globals())
timeit.timeit("cookie = Cookie('key', 'value')\nstr(cookie)", number=1000000, globals=globals())
timeit.timeit("cookie = Cookie('key', 'value', domain='example.com', path='/foo', max_age=600, httponly=True)\nstr(cookie)", number=1000000, globals=globals())
from cookies import Cookies, Cookie
cookies = Cookies()
timeit.timeit("""cookies.parse_request('simple=value')""", number=1000000, globals=globals())
timeit.timeit("""cookies.parse_request('simple="with%20encoded"')""", number=1000000, globals=globals())
timeit.timeit("cookies.parse_request('a=b; foo=bar; bar=baz;')", number=1000000, globals=globals())
timeit.timeit("cookie = Cookie('key', 'value')\ncookie.render_response()", number=1000000, globals=globals())
timeit.timeit("cookie = Cookie('key', 'value', domain='example.com', path='/foo', max_age=600, httponly=True)\ncookie.render_response()", number=1000000, globals=globals())
from http.cookies import SimpleCookie
cookies = SimpleCookie()
timeit.timeit("cookies.load('simple=value')", number=1000000, globals=globals())
timeit.timeit("""cookies.load('simple="with%20encoded"')""", number=1000000, globals=globals())
timeit.timeit("cookies.load('a=b; foo=bar; bar=baz;')", number=1000000, globals=globals())
timeit.timeit("cookie = SimpleCookie()\ncookie['key'] = 'value')\nstr(cookie)", number=1000000, globals=globals())
timeit.timeit("cookie = SimpleCookie()\ncookie['key'] = 'value'\ncookie['key']['domain'] = 'example.com'\ncookie['key']['path'] = '/foo'\ncookie['key']['httponly'] = True\ncookie['key']['max-age'] = 600\nstr(cookie)", number=1000000, globals=globals())