渲染图形时调试速度很慢 [英] Debug is very slow when rendering graphics

查看:89
本文介绍了渲染图形时调试速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序制作了一些复杂的图形显示,并且在调试模式下,这些渲染速度太慢以致无法使用.一个典型的示例在释放模式下需要1.5秒,而在调试模式下需要1.5秒 分钟来显示图片.这是原来的60倍.我可以理解大约两个或三个因素,但是显然是错误的.

My application makes some complicated graphics displays, and in debug mode these are rendered so slowly as to be unusable.  A typical example takes, in release mode 1.5 seconds, while in debug mode, 1.5 minutes, to display the picture.  That's 60 times longer.  I can understand a factor of perhaps two or three, but something's clearly wrong.

我尝试打开优化功能(通常在调试模式下关闭),但没有任何改善.我还尝试了其他一些编译器,调试设置失败.

I've tried turning on optimization (which is usually off in debug mode), with no improvement.  I have also experimented with some other compiler and  debug settings without success.

程序将创建一个C型指针数组,以保存图形的每个元素,线条的起点和终点,文本的位置等.复杂情况中有成千上万个.创建该数组可能是瓶颈-但不是 唯一的.当图片最终显示出来时,如果我调整窗口的大小,然后启动OnDraw()例程并从该数组中读取数据,则重新绘制的速度也会非常缓慢.在屏幕上书写文字时,好像有人在输入 实时,只比我输入的速度快一点.

The program creates a C-typed pointer array to hold each element of the drawing, line start and end points, location of text, and so on.  There are thousands of those in a complex picture.  Creating that array might be the bottleneck -- but not the only one.  When the picture finally shows up, if I resize the window, which starts the OnDraw() routine and reads the data from that array, the redraw is also painfully slow.  When writing text on the screen, it looks like someone is typing in real time, only slightly faster than I can type.

有人可以建议一些设置来解决此问题吗?

Can anyone suggest some settings to cure this problem?

推荐答案

还有更多数据:

Here are some more data:

我这样定义我的数组:

CLine类:公共CObject
{
公开:
     int m_Color;
     float m_X1,m_Y1,m_X2,m_Y2;

     CLine(int Color,浮点数X1,浮点数Y1,浮点数X2,浮点数Y2)
     {
         m_Color =颜色;
         m_X1 = X1;
         m_X2 = X2;
         m_Y1 = Y1;
         m_Y2 = Y2;
    }
     void Draw(CDC * pDC);
};

class CLine : public CObject
{
public:
    int m_Color;
    float m_X1, m_Y1, m_X2, m_Y2;

    CLine ( int Color, float X1, float Y1, float X2, float Y2 )
    {
        m_Color = Color;
        m_X1 = X1;
        m_X2 = X2;
        m_Y1 = Y1;
        m_Y2 = Y2;
    }
    void Draw( CDC *pDC );
};

然后我用数据填充它:

void CGraphicsDoc :: AddLine(int jcol,浮点数X1,浮点数Y1,浮点数X2,浮点数Y2)
{
     CLine * PLine =新的CLine(jcol,X1,Y1,X2,Y2);
     m_LineArray.Add(PLine);

void CGraphicsDoc::AddLine(int jcol, float X1, float Y1, float X2, float Y2)
{
    CLine* PLine = new CLine ( jcol, X1, Y1, X2, Y2 );
    m_LineArray.Add( PLine );

瓶颈似乎在呼唤new.调试模式是否会做永久的事情?

The bottleneck seems to be on the call to new.  Is debug mode doing something that would take forever?


这篇关于渲染图形时调试速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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