[Kst] branches/work/kst/portto4/kst/src/datasources/ascii

Peter Kümmel syntheticpp at gmx.net
Mon Oct 22 10:11:04 UTC 2012


SVN commit 1321911 by kuemmel:

only use threads for files > 1 MB

 M  +11 -3     asciisource.cpp  
 M  +1 -0      asciisource.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1321910:1321911
@@ -250,6 +250,14 @@
 
 
 //-------------------------------------------------------------------------------------------
+bool AsciiSource::useThreads() const
+{
+  // only use threads for files > 1 MB
+  return _config._useThreads && _byteLength > 1 * 1024 * 1024;
+}
+
+
+//-------------------------------------------------------------------------------------------
 int AsciiSource::tryReadField(double *v, const QString& field, int s, int n)
 {
   if (n < 0) {
@@ -283,7 +291,7 @@
     _fileBuffer.setFile(file);
 
     int numThreads;
-    if (!_config._useThreads) {
+    if (!useThreads()) {
       numThreads = 1;
     } else {
       numThreads = QThread::idealThreadCount();
@@ -291,7 +299,7 @@
     }
 
     if (useSlidingWindow(bytesToRead)) {
-      if (_config._useThreads) {
+      if (useThreads()) {
         _fileBuffer.useSlidingWindowWithChunks(_reader.rowIndex(), begin, bytesToRead, _config._limitFileBufferSize, numThreads);
       } else {
         _fileBuffer.useSlidingWindow(_reader.rowIndex(), begin, bytesToRead, _config._limitFileBufferSize);
@@ -316,7 +324,7 @@
   for (int i = 0; i < slidingWindow.size(); i++) {
 
     int read;
-    if (_config._useThreads)
+    if (useThreads())
       read = parseWindowMultithreaded(slidingWindow[i], col, v, field);
     else
       read = parseWindowSinglethreaded(slidingWindow[i], col, v, field, sampleRead);
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1321910:1321911
@@ -83,6 +83,7 @@
     QStringList _fieldList;
     QMap<QString, QString> _fieldUnits;
 
+    bool useThreads() const;
     bool useSlidingWindow(int bytesToRead)  const;
 
     int tryReadField(double *v, const QString &field, int s, int n);


More information about the Kst mailing list