Skip to content

Instantly share code, notes, and snippets.

@smetj
Created December 10, 2012 20:12
Show Gist options
  • Save smetj/4253033 to your computer and use it in GitHub Desktop.
Save smetj/4253033 to your computer and use it in GitHub Desktop.
Measure impact of constantly initializing classes.
https://github.com/smetj/experiments/blob/master/python/testlap/measure_class_init_impact.py
[smetj@indigo testlap]$ python measure_class_init_impact.py
Running test_1
OK
Running test_2
OK
2.7.3 (default, Jul 24 2012, 10:05:38)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)]
Linux-3.6.6-1.fc17.x86_64-x86_64-with-fedora-17-Beefy_Miracle
Figure out whether initializing a class is expensive.
+----------+-------------------------------------------------+--------+--------------+
| Function | Description | Result | Seconds |
+----------+-------------------------------------------------+--------+--------------+
| test_1 | Just call a local function. | OK | 3.0289080143 |
| test_2 | Initialize a class and call a function from it. | OK | 7.460447073 |
+----------+-------------------------------------------------+--------+--------------+
[smetj@indigo testlap]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment