Skip to content

Instantly share code, notes, and snippets.

@teisman
Last active December 17, 2015 23:29
Show Gist options
  • Save teisman/5689497 to your computer and use it in GitHub Desktop.
Save teisman/5689497 to your computer and use it in GitHub Desktop.
# MongoEngine's useful tool called query_counter
from mongoengine.context_managers import query_counter
# Initialize counter
c = query_counter()
with c:
# make MongoDB calls via MongoEngine API
# e.g. User.objects.all()
pass
# Print the number of MongoDB queries that were made in the above statements
print c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment