profile python应用程序联机,在浏览器中显示flamegraph

profiler_online的Python项目详细描述


## 项目名

`profiler_online`

### 介绍:
用来解析查找python程序可能存在的各方面性能或者奇葩问题的工具,通过web访问访问可以直接拿到火焰吐.

Will Add Future:

* 加入内存的相关信息
* 查询时间范围

### 安装:

**pypi:**

```
pip install profiler_online
```

**源码安装:**

```
git clone https://github.com/rfyiamcool/profiler_online.git
cd profiler_online
python setup.py install
```


### 用法:

这边已经封装好了,你需要做的只是把性能分析模块引入到你的应用里面.

```
from profiler_online import run_profiler
run_profiler()
```

### 测试:

打开浏览器 http://127.0.0.1:8080 这样就可以显示正在运行服务的性能火焰图了.

![image](https://github.com/rfyiamcool/profiler_online/raw/master/img/demo.png)

### 问题:

下面是以前创建火焰图的方法.

```
python test.py
curl "127.0.0.1:8080" | profiler_online/tools/flamegraph.pl > flame.html
```

改进的方法:
```
直接浏览器打开,地址栏 --> 127.0.0.1:8080
```

在开发过程中,遇到了python系统调用时不能正常捕获输出. 现在已经改为临时文件的方式.
```
cmdstr = './profiler_online/tools/flamegraph.pl'
p = subprocess.Popen(cmdstr, stdin = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
p.stdin.write(stats)
p.stdin.flush()
try:
if p.stderr:
stats = p.stderr.read()
p.stderr.flush()
if p.stdout:
stats = p.stdout.read()
except Exception, e:
print e,Exception
```

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java错误:无法解析方法   如何用相同的父标记和子标记在Java中解析XML?   日期使用Java中的时区偏移将本地时间转换为UTC   java如何在多进程、多线程环境中读取文件   WebView中的java弹出式对话框不在当前显示范围内,但在chrome浏览器中运行良好   只有2个参数的java递归二进制搜索方法   无法在java中调用函数   java JavaMail在Tomcat服务器上运行时停止工作   反射通过java程序生成、编译和运行java类   java Android:如何使ListView即使在应用程序关闭后仍保持禁用状态   在JAVA中识别匿名类实例   java渲染一个由三角形组成的立方体,在旋转时会产生奇怪的角度   函数式编程如何基于比较连续的列表元素将Java流减少为布尔值   java如何替换列表中的多个项目?   java Android如何获取随机sqlite数据?   java我已经将useSSL设置为false,但仍然收到警告   java使用动态变量生成jlabel   apachespark:java。lang.NoClassDefFoundError v2TableWithV1回退