Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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