This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cProfile import Profile | |
from functools import wraps | |
import pstats | |
def profiled(f): | |
""" | |
Decorator for profiling a function | |
To use: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a pattern I like but I always forget the details | |
class Boo(object): | |
def __init__(self): | |
self.foo = u"☃" | |
def __unicode__(self): | |
return u"Boo(foo={})".format(self.foo) | |
def __str__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(classes = MyConfigurationClass.class) | |
public class MyTest { | |
@Autowired | |
private MyWhateverType myConfiguredBean; | |
@Test | |
public void testMyConfiguredBean() { | |
System.out.println("works"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Ballpark reference on function call, thread, process overhead | |
bender@dishoftheday:work$ python3 overhead.py 1000 | |
forloop: 0.030994415283203125 ms | |
funcloop: 0.17786026000976562 ms | |
threadloop: 110.0301742553711 ms | |
threadloop2: 85.56795120239258 ms | |
threadloop_p: 77.57711410522461 ms | |
procloop: 5104.6202182769775 ms |
OlderNewer