User forums > Using Code::Blocks
Code::Blocks very slow to open long files
oBFusCATed:
Hello,
I can confirm that it is not an Ubuntu only issue.
It is slow on my machine at home: gentoo amd64 opteron 2.0ghz c::b svn 5028 wx 2.8.7
Best regards
Deschamps:
--- Quote from: oBFusCATed on May 08, 2008, 01:43:12 am ---I can confirm that it is not an Ubuntu only issue.
It is slow on my machine at home: gentoo amd64 opteron 2.0ghz c::b svn 5028 wx 2.8.7
--- End quote ---
The same issue here. Almost 5 seconds to open the TXT file.
openSUSE 10.3 x86_64 on a Core2Duo T7500 laptop w/3GB RAM and SATA HD
C::B svn 5013 compiled against wxGTK 2.8.7 Unicode
Regards.
dmoore:
It probably doesn't make any difference, but why do we use
--- Code: --- wxWCharBuffer wideBuff = conv.cMB2WC((char*)buffer, size + 4 - m_BOMSizeInBytes, &outlen);
m_ConvStr = wxString(wideBuff);
--- End code ---
instead of
--- Code: --- m_ConvStr = wxString((char*)buffer,conv);
outlen = m_ConvStr.Len();
--- End code ---
Biplab:
--- Quote from: dmoore on May 08, 2008, 04:31:34 pm ---It probably doesn't make any difference, but why do we use
--- End quote ---
I don't remember exactly why I used such a workaround. Probably due to some crash. :)
I've found out a better solution for this problem. :D
If we use iconv based implementation, the conversion routine becomes faster. Just apply the following patch and see the difference.
--- Code: ---Index: src/sdk/encodingdetector.cpp
===================================================================
--- src/sdk/encodingdetector.cpp (revision 5040)
+++ src/sdk/encodingdetector.cpp (working copy)
@@ -19,6 +19,8 @@
#include "encodingdetector.h"
#include "filemanager.h"
+#include <wx/stopwatch.h>
+#include <iconv.h>
EncodingDetector::EncodingDetector(const wxString& filename)
@@ -106,9 +108,25 @@
/* NOTE (Biplab#5#): FileManager returns a buffer with 4 extra NULL chars appended.
But the buffer size is returned sans the NULL chars */
+ /*wxStopWatch sw;
+ sw.Start();
wxWCharBuffer wideBuff = conv.cMB2WC((char*)buffer, size + 4 - m_BOMSizeInBytes, &outlen);
m_ConvStr = wxString(wideBuff);
+ sw.Pause();
+ Manager::Get()->GetLogManager()->DebugLog(wxString::Format(_T("Time taken: %d milliseconds\n"), sw.Time() ));*/
+ wxStopWatch sw;
+ iconv_t cd = iconv_open("ISO-8859-1", "UTF-8");
+ size_t inbytesleft = 0, outbytesleft = 0;
+ char* outbuf = new char[size + 4 - m_BOMSizeInBytes];
+ sw.Start();
+ iconv(cd, (char **)&buffer, &inbytesleft, &outbuf, &outbytesleft);
+ sw.Pause();
+ m_ConvStr = wxString((wchar_t *)outbuf);
+ delete [] outbuf;
+ iconv_close(cd);
+ Manager::Get()->GetLogManager()->DebugLog(wxString::Format(_T("Time taken: %d milliseconds\n"), sw.Time() ));
+
if (outlen == 0)
{
// Possibly the conversion has failed. Let's try with System-default encoding
--- End code ---
Using wx based implementation:
--- Quote ---Time taken: 6201 milliseconds
--- End quote ---
Using iconv based implementation:
--- Quote ---Time taken: 0 millisecond
--- End quote ---
The patch contains commented old code. You can easily compare the performance by commenting out new / old code.
Please note: The iconv based implementation code is NOT generic one. It would work only with the log file.
PS: Please bear with my late replies. :)
MortenMacFly:
--- Quote from: Biplab on May 08, 2008, 06:54:44 pm ---If we use iconv based implementation, the conversion routine becomes faster. [...]
--- End quote ---
Although this is a very nice idea anyways, but you are aware, that this massively "complicates" the compilation on Windows, right? Because MinGW does not ship with this lib so we would have to bundle iconv with the C::B sources on Windows. I'm not sure on how many libs iconv itself depends but I would guess it's not a "stand-alone". So the question is either we find another solution or probably (as this seems to be a Linux only thing) we make this implementation on Linux only... Any thoughts?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version