[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: Faster saving (Re: Global save method option)
From: Nicolas Goutte <nicolasg () snafu ! de>
Date: 2004-02-15 15:56:04
Message-ID: 200402151656.04997.nicolasg () snafu ! de
[Download RAW message or body]
On Saturday 14 February 2004 11:53, David Faure wrote:
> On Saturday 14 February 2004 03:57, Nicolas Goutte wrote:
> > So for the maindoc.xml of the KWord demo flatland.kwd, I get:
> > 4.99 s by QCString
> > 13,44 s by QDomDocument::save (however that is then without indenting.)
> > 18.47 s by QTextStream::operator <<
>
> I see. When sending the data little by little to KZip, we end up doing much
> more I/O (and also triggering the zlib algorithms all the time, with very
> little data) and the result is much slower. That's not good. IMHO we need
> buffering at some level, either KZip or KoStore.... Hmm, this isn't going
> to require an intermediate QIODevice, like a QBuffer, which itself writes
> out the data in bigger chunks into KZip.
I think that if useful, the buffering can also be done in koStoreDevice.
>
> .... some time later ...
>
> I wrote KBufferedIODevice, see attachment. If it works, we could put it in
> kdelibs and use it transparently from KZip itself - but I don't have time
> to do that today.
>
> For now, could you try if it makes things faster, using it this way?
Well, it does, but it is still not as fast as using QCString.
I have used KoDocument:.saveToStream to test (see attached patch), again with
flatland.kwd
It has taken (rounded values):
QCString: 19s
QTextStream: 55s
KBufferedIODevice( 8KB ): 41s
KBufferedIODevice( 64KB ): 35s
KBufferedIODevice( 128KB ): 34s
So something is still worng.
Meanwhile I have the feeling that we should wait on Qt4. If Qt4's speed is
really optimized, the value that we would get could be very different.
>
> KBufferedIODevice bufdev( dev );
> <then write to bufdev instead of dev, e.g. using QTextStream and save()>
> bufdev.close();
>
> > It must be:
> > doc.save (s, 0)
> > but then there is not any indent.
>
> In fact it should be (s,1) like toString() does.
Have a nice day!
["test.diff" (text/x-diff)]
Index: koDocument.cc
===================================================================
RCS file: /home/kde/koffice/lib/kofficecore/koDocument.cc,v
retrieving revision 1.290
diff -u -p -r1.290 koDocument.cc
--- koDocument.cc 31 Jan 2004 10:26:33 -0000 1.290
+++ koDocument.cc 15 Feb 2004 15:42:44 -0000
@@ -975,6 +975,10 @@ bool KoDocument::saveNativeFormat( const
bool KoDocument::saveToStream( QIODevice * dev )
{
+ bool flag = false;
+ QTime time;
+ time.start();
+#if 0
QDomDocument doc = saveXML();
// Save to buffer
QCString s = doc.toCString(); // utf8 already
@@ -983,7 +987,26 @@ bool KoDocument::saveToStream( QIODevice
int nwritten = dev->writeBlock( s.data(), s.size()-1 );
if ( nwritten != (int)s.size()-1 )
kdWarning(30003) << "KoDocument::saveToStream wrote " << nwritten << " - \
expected " << s.size()-1 << endl;
- return nwritten == (int)s.size()-1;
+ flag = nwritten == (int)s.size()-1;
+#elif 0
+ dev->resetStatus();
+ QTextStream stream( dev );
+ stream.setEncoding( QTextStream::UnicodeUTF8 );
+ stream << saveXML();
+ flag = ( dev->status() == IO_Ok );
+#else
+#include <kbufferediodevice.h>
+ KBufferedIODevice buf( dev, 64 * 1024 );
+ buf.open( IO_WriteOnly );
+ dev->resetStatus();
+ QTextStream stream( &buf );
+ stream.setEncoding( QTextStream::UnicodeUTF8 );
+ stream << saveXML();
+ buf.close();
+ flag = ( dev->status() == IO_Ok );
+#endif
+ kdDebug(30003) << "@@@ TIME: " << time.elapsed() << endl;
+ return flag;
}
bool KoDocument::saveToStore( KoStore* _store, const QString & _path )
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic