TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Chronic - Python Instrumentation

34 点作者 dcraw超过 11 年前

4 条评论

JeffJenkins超过 11 年前
This is cool. I implemented an extremely similar system for my last job. The data was dumped into mongo and then we visualized it with stacked bar graphs.<p>One thing to consider since you&#x27;re using a count+total model is that the most interesting timings will often be the 90th or 99th percentile, so by calculating averages you might be missing useful information.<p>I ran into some issues with the implementation after switching to using an async framework since the code was no longer a series of nested function calls. Since the current best practice is coroutines where this will still work I think it&#x27;s okay, but you should consider how someone using callbacks might time their code. In my case I was in a hurry so I manually called the equivalent of your __enter__ and __exit__, but it was pretty ugly and left a lot of room for bugs.
评论 #6838214 未加载
smilliken超过 11 年前
See also: <a href="http://pycounters.readthedocs.org/en/latest/" rel="nofollow">http:&#x2F;&#x2F;pycounters.readthedocs.org&#x2F;en&#x2F;latest&#x2F;</a>
评论 #6832392 未加载
drdaeman超过 11 年前
Trivial but useful. Next time, instead of kicking in my own custom timing decorator (5-liner, but...) I&#x27;ll probably use this. [Edit: pycounter looks even nicer, didn&#x27;t heard of them before, thanks for sharing!]<p>The only downside I see, it does record function name, but doesn&#x27;t record module name (and, for class members, classname). For example, it wouldn&#x27;t be too useful to see &quot;authorize&quot; instead of &quot;ppp.common.authorize&quot; in RADIUS server profiling logs. :)
评论 #6832421 未加载
评论 #6832422 未加载
armon超过 11 年前
We built a similar decorator&#x2F;context manager for profiling, but it is really much more useful if you can export the data to statsite + graphite so that you can graph and view it on an on going basis. The insight into the runtime is much more valuable when you have historic data to compare it to.