???????????????????????????У??????????????????????????????????????30???????????????(30??)??????????30?????????????????????????????????????????????????????20?????
????????????????????????????????豸?????????????1s??1*2*30?60s????????????????5????????????????20???????С?????????????
????????????????????
????1.review????????
??????1?????????????????sleep???review???
???????????Ч??????????????sleep???????????н?Σ?60???????????£??????????sleep????????????23???????
???????????????????????????????????????????汾??????????????????????????????????????????
????2.????????????????????
?????????????????????????????????????
????def costs(fn):
????def _wrapper(*args?? **kwargs):
????start = time.time()
????fn(*args?? **kwargs)
????print "%s ????cost %s ??" % (fn.__name__?? time.time() - start)
????return _wrapper
????def costs_with_info(info):
????def _wrapper(fn):
????print "info: " + info
????return costs(fn)
????return _wrapper
????????????????????????@costs????@costs_with_info("some infomation")
????@costs
????def configureQuickStart(self?? pkg_name):
????if self.config.allow_quick_start == "1":
????self.logger.info("Disable quick start: %s" % pkg_name)
????self.disableQuickStartSnapShot(pkg_name)
????else:
????self.logger.info("Quick start is enabled: %s" % pkg_name)
?????????????????????????????????????????Ч?????????????????????
????????????Android???traceview??traceview?з?????????????????????????????????????python?????????????????????????????cProfile?????????????????????
????3.???cProfile???з???
??????1??????????????????result.prof?????????log???????tottime?????????????????????
????import cProfile
????import pstats
????cProfile.run('main()'?? filename='result.prof'?? sort="tottime")
????p = pstats.Stats('result.prof')
????p.sort_stats('time').print_stats()
????log????????????????

?????????????????????????????????????????????????????????????????graphviz??
????????????????
????sudo apt-get install graphviz
???????????Gprof2Dot??????????
????python gprof2dot.py -f pstats result.out | dot -Tpng -o result.png
???????????????????????????????????
????????????£?

?????????????????????????????????????????????????????????????????У?30??????????95.29%?????????sleep?????????????????????????????????????sleep??????????????Щ???????????