Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@deckar01
Created August 20, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deckar01/7643bb78a2dd04375fd2c16f90b9f052 to your computer and use it in GitHub Desktop.
Save deckar01/7643bb78a2dd04375fd2c16f90b9f052 to your computer and use it in GitHub Desktop.
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