为什么在eclipse / pydev中调试这么慢我的python程序? [英] Why is debugging in eclipse/pydev so slow for my python program?

查看:254
本文介绍了为什么在eclipse / pydev中调试这么慢我的python程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个比较简单(没有类)的python 2.7程序。程序第一件事就是将sqlite dbase读入一个字典。数据库很大,但不是很大,在磁盘上大约90Meg。读取数据库需要大约20秒钟。在读取数据库后,我初始化一些变量,例如

  localMax = 0 
localMin = 0
firstTime = True

当我在Eclipse-3.7中调试该程序时。 0 / pydev - 即使是这些简单的线 - 调试器中的每一个步骤都会占用一个内核的100%,并且需要5到10秒钟。我可以看到python进程达到100%cpu 10秒。单步...等待10秒...单步...等待10秒...如果我在命令行调试只使用pdb,没有问题。如果我没有调试,程序运行在正常的速度,没有什么奇怪的像在Eclipse。



我已经在双核Win7 PC w / 4G内存,我的8核Ubuntu盒W / 8G的内存,甚至我的Mac Air。多平台开发怎么样?我一直认为它会在某个地方工作。在任何时候,我永远都不会离开内存。



在每个Eclipse的单步骤中,为什么python进程跳到100%的CPU,并采取10秒?

解决方案

这是一个很好的解决方案,基于Mikko Ohtamaa的提示。我刚刚在Mac Air上验证了以下内容:




  • 如果我简单地关闭Eclipse GUI中的变量窗口,我可以单步通过代码正常速度。哪个是好的,但是我没有变量窗口。

  • 对于任何我想要看到的变量,我可以将鼠标悬停在变量上,并查看该值。我没有试图将我的大字典悬停在这里的罪魁祸首。

  • 我也可以右键单击任何变量,并添加一个'Watch',它会显示一个'表达式'窗口。在这种情况下,变量只是一个'表达式'的简并状态(非常简单的情况)。



所以,我的解决方法是关闭Eclipse变量窗口,并使用表达式窗口来选择性地查看变量。一个痛苦,但是我正在做的这个调试比pdb要好。


I have a relatively simple (no classes) python 2.7 program. The first thing the program does is read an sqlite dbase into a dictionary. The database is large, but not huge, around 90Meg on disk. It takes about 20 seconds to read in. After reading in the database I initialize some variables, e.g.

localMax = 0
localMin = 0
firstTime = True

When I debug this program in Eclipse-3.7.0/pydev - even these simple lines - each single-step in the debugger eats up 100% of a core, and takes between 5 and 10 seconds. I can see the python process goes to 100% cpu for 10 seconds. Single-step... wait 10 seconds... single-step... wait 10 seconds... If I debug at the command line just using pdb, no problems. If I'm not debugging at all, the program runs at "normal" speed, nothing strange like in Eclipse.

I've reproduced this on a dual core Win7 PC w/ 4G memory, my 8 core Ubuntu box w/ 8G of memory, and even my Mac Air. How's that for multi-platform development! I kept thinking it would work somewhere. I'm never even close to running out of memory at any time.

On each Eclipse single-step, why does the python process jump to 100% CPU, and take 10 seconds?

解决方案

Here is a good enough workaround, based on Mikko Ohtamaa's hint. I just verified the following on my Mac Air:

  • If I simply close the 'Variables' window in the Eclipse GUI, I can single step through the code at normal speed. Which is great, but, uh, I don't have the Variables window.
  • For any variable I want to see, I can hover my cursor over the variable and see the value. I didn't attempt to hover over my large dictionary that is the culprit here.
  • I can also right-click on any variable and add a 'Watch', which brings up an 'Expressions' window. In this case the variable is just a degenerate case (very simple case) of an 'expression.

So, the workaround for me is to close the Eclipse Variable window, and use the Expressions window to selectively view variables. A pain, but for the debugging I'm doing it is better than pdb.

这篇关于为什么在eclipse / pydev中调试这么慢我的python程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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