[Qt-interest] Demo Browser and Qt::Concurrent query
Nitin Mahajan
nitinm76 at yahoo.com
Fri Jan 29 16:47:10 CET 2010
Hello,
--- On Fri, 22/1/10, Benjamin Meyer <ben at meyerhome.net> wrote:
> From: Benjamin Meyer <ben at meyerhome.net>
> Subject: Re: [Qt-interest] Demo Browser and Qt::Concurrent query
> To:
> Cc: qt-interest at trolltech.com
> Date: Friday, 22 January, 2010, 2:37 AM
> There was a number of spots in the
> demo browsers download window that had nothing to do with
> downloading that were using up the cpu (repainting when it
> wasn't necessary). They have been changed in
> Arora. I would suggest profiling your code to find
> (and fix) those problems.
>
I did profiling for the demo browser code
1. With Callgrind on Desktop
2. With gprof on ARM
In both the cases I am getting information about the functions which took most of the time, during the life span of the browser process(though I did only download after starting the browser). However after going through these functions, I understood that though they took more time in browser they may not be the functions which get called periodically during download(I did put prints in them to verify) thus resulting into jumpy mouse movements.
Can I get some pointers on how to zero in towards the part of code which actually results into jumpy mouse movements.
Also the options --zero-before and --dump-after doesn't seem to be working for callgrind. When I specified these with -v, I could see the dump happening only after I close the browser program and not immediately after leaving the function specified with --dump-after.
regards
Nitin
> -Benjamin Meyer
>
> On Jan 20, 2010, at 12:27 AM, Nitin Mahajan wrote:
>
> > Hello,
> >
> > I was trying the download functionality in demo
> browser. I am running Qt for Embedded Linux 4.5.3 on a ARM
> based board.
> >
> > What I observe is that when I start the dowload of
> some file, the UI becomes very slow, meaning mouse cursor
> movement is jumpy.
> >
> > To solve this I thought of seperating out the
> functionality in DownloadItem::downloadReadyRead() in a
> seperate thread. This I did using QtConcurrent::run().
> >
> > This is how I did it, just moved the functionality
> from slot downloadReadyRead() to a fucntion named
> threadDownloadReadyRead() and passed this function to
> QtConcurrent::run().
> >
> > The mouse movement is still jumpy though the file
> writing a happening in a seperate thread.
> >
> > Am I missing something while using QtConcurrent or
> that is not the right operation to be shifted to a new
> thread? Can I get some pointers towards this?
> >
> >
> >
> > void DownloadItem::downloadReadyRead()
> > {
> > QFuture<void> future =
> QtConcurrent::run(this,
> &DownloadItem::threadDownloadReadyRead);
> > }
> >
> > void DownloadItem::threadDownloadReadyRead()
> > {
> > qint64 (QFile::*fn)(const
> QByteArray &byteArray) = &QFile::write;
> > //printf("\nThread Id for download
> ready read is %x\n",(unsigned int)
> QThread::currentThread());
> > if (m_requestFileName &&
> m_output.fileName().isEmpty())
> > return;
> > if
> (m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
> != 200)
> > return;
> > if (!m_output.isOpen()) {
> > // in case someone else has
> already put a file there
> > if (!m_requestFileName)
> >
> getFileName();
> > if
> (!m_output.open(QIODevice::WriteOnly)) {
> >
> downloadInfoLabel->setText(tr("Error opening save file:
> %1")
> >
> .arg(m_output.errorString()));
> >
> stopButton->click();
> > emit
> statusChanged();
> > return;
> > }
> > emit statusChanged();
> > }
> >
> > if (-1 == m_output.write(m_reply->readAll())) {
> >
> downloadInfoLabel->setText(tr("Error saving: %1")
> >
> .arg(m_output.errorString()));
> > stopButton->click();
> > }
> >
> > }
> >
> >
> > regards
> >
> > -Nitin
> >
> >
> > New Email names for you!
> > Get the Email name you've always wanted on the new
> @ymail and @rocketmail.
> > Hurry before someone else does!
> > http://mail.promotions.yahoo.com/newdomains/aa/
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
New Email addresses available on Yahoo!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/
More information about the Qt-interest-old
mailing list