An important performance measurement for code is the number of MongoDB and/or MySQL calls the code makes. Each call is likely a network round-trip in the production environment, which is relatively costly. So the number of calls should generally be minimized and tests should be written that monitors the amount of expected MongoDB / MySQL calls.
MongoDB Call Counting
There's a few Python context managers used to count MongoDB calls:
...
Code Block | ||
---|---|---|
| ||
with check_mongo_calls(0): _course_overview_2 = CourseOverview.get_from_id(course.id) |
MySQL Call Counting
MySQL queries are counted with a context manager provided by the Django framework - django.test.TestCase.assertNumQueries.
...
Code Block | ||
---|---|---|
| ||
with self.assertNumQueries(0): outcomes.store_outcome_parameters(params, self.user, self.consumer) |
XBlock Instantiation Counting
Instantiating XBlocks can be expensive, and large numbers of instantiations can be indicative of a bad query pattern.
...