Created
August 20, 2018 22:02
-
-
Save deckar01/7643bb78a2dd04375fd2c16f90b9f052 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cProfile | |
from marshmallow import Schema | |
BRANCH = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() | |
values = (1, True, '3') | |
class ImplicitSchema(Schema): | |
class Meta: | |
fields = ('a', 'b', 'c') | |
schema = ImplicitSchema() | |
def main(static): | |
offset = 0 if static else 1 | |
for i in range(10000): | |
result = schema.dump({ | |
'a': values[(i*offset + 0) % 3], | |
'b': values[(i*offset + 1) % 3], | |
'c': values[(i*offset + 2) % 3], | |
}) | |
def profile(static): | |
filename = '{}-{}.prof'.format( | |
BRANCH, | |
'static' if static else 'changing', | |
) | |
cProfile.run('main({})'.format(static), filename) | |
for static in (True, False): | |
profile(static) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment