在py.test执行期间分析cpu和内存使用情况 [英] Profile cpu and memory usage during py.test execution

查看:205
本文介绍了在py.test执行期间分析cpu和内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临以下项目.我要创建一组执行性能测试套件的过程中显示CPU和内存级别的图片.任何建议,我将不胜感激.

I am facing the following project. I want to create pictures showing the cpu and memory level during the execution of a set of performance test suites. I would appreciate any suggestion.

目前我正在考虑的唯一方法是使用命令top或python模块 psutil 并与测试并行执行.但是我想知道是否已经存在更好的方法,可能是py.test插件.

Currently the only approach I am considering is to use the command top or the python module psutil and execute them in parallel to the tests. However I was wondering whether there exists already a better approach, may be a py.test plugin.

一个不错的选择是能够比较一个执行与另一个执行之间的参数.

A nice to have would be be able to compare those parameters from one execution to another.

测试是在Linux(Ubuntu)下执行的.

The tests are executed Under Linux (Ubuntu).

推荐答案

有很多方法可以做到这一点,从获取广泛的系统统计信息然后取平均值(顶部),再到使用处理器硬件计数器(例如使用英特尔VTune).

There are a whole bunch of ways of doing this, ranging from getting broad system statistics and then averaging them (top), to using processor hardware counters (e.g. using Intel VTune).

psutil看起来非常好.我唯一的意见是确保您进行多次测量,然后对它们进行平均以消除杂散的尖峰等.

psutil seems perfectly fine. My only comment is to make sure you take many measurements and then average them to get rid of spurious spikes and such.

进行这些测量的其他一些可能方法是/proc/[pid]/stat (请参见手册页), Windows .

Some other possible ways of taking these measurements are /proc/[pid]/stat (see man page), time, or if you get really obsessive, you can use some programatic techniques, e.g. for Windows.

以下是有关通过编程获取基准值的很好的讨论.它还讨论了您可能会遇到的一些陷阱,即使您没有使用编程方法,也应该熟悉这些陷阱.

Here's a good discussion about programmatically getting benchmarking values. It also discusses some of the traps you can get into, which you should be familiar with even if you are not using a programmatic method.

英特尔拥有许多有关处理器基准测试的良好信息;是他们的面包和黄油.

Intel has a lot of good information about processor benchmarking; it's their bread and butter.

我只能发表的另一条评论是,您需要仔细选择基准.英特尔强调CPU,因为这是它们最擅长的.其他公司也是如此.实际上,有许多其他重要因素会发挥作用,具体取决于在应用程序域上.

The only other comment I can make is that you need to select your benchmark carefully. Intel emphasizes CPU because it is what they are best at. The same is true for other companies. In truth, there are a whole host of other important factors that come into play depending upon the application domain.

查看不同的基于媒体的基准.它们可能比仅基于处理器时间的方法更为合适.我无法轻松找到基准,但是bing是一个奇迹.

Look at the different media-based benchmarks. They may be more appropriate than one simply based upon processor time. I can't readily find the benchmarks but bing is a wonder.

这篇关于在py.test执行期间分析cpu和内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆