Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. File Searching operation taking more time using qt
Forum Updated to NodeBB v4.3 + New Features

File Searching operation taking more time using qt

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rashmi
    wrote on last edited by
    #1

    Hi all,
    In my device, 500 files are in database.
    In our application, we search file from 500 files.
    Suppose same file name have upto 200 files ,we observed that searching operation consuming more time.
    Could you please let me know why its taking more time.
    Thanks

    I

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mvuori
      wrote on last edited by
      #2

      Hard to say with the information provided. More information would be needed:

      • Files are in a database. What kind of database?
      • Are there contents or perhaps just filenames?
      • How do you do the searching? Your Qt code?
      • Consumes more time compared with what other method?
      • How much more is "more time"? Millisecond? 10 percent? Ten times?
      • Your device, its characteristics, OS, Qt version?
      1 Reply Last reply
      4
      • R Offline
        R Offline
        Rashmi
        wrote on last edited by
        #3

        I am using Linux and 4.4.3 qt version for arm processor.
        Processor frequency is 200Mhz.
        Following is code snippest:
        foreach(QString patientIdStr, m_patientList)
        {
        if (patientIdStr.startsWith(ui->editSearch->text()))
        {
        QString patientId = patientIdStr.section('_', 1, 1);

                testReportIds = CDatabaseManager::instance()->GetTestReportIdsWithPatient(patientId);
        
                if (!testReportIds.isEmpty())
                {
                    for (int index = 0; index < testReportIds.count(); index++)
                    {
                        m_testReportList.append(testReportIds.at(index));
                        patientIds.append(patientIdStr);
                    }
                }
                else
                {
                    m_testReportList.append("");
                    patientIds.append(patientIdStr);
                }
            }
        }
        

        In this , its searches entered letter with existing files.
        Suppose 194 patient name which is start with letter "C" are present in database.
        The above code taking around 150 sec to serach patient Id for 194 patient from existing database.

        Can you explain how foreach works.
        Is any other alternative to make fast search.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Not everything comes from that but your code is not the most efficient.

          For example:

          • patientIdStr, the way you wrote it, you create a copy at each iteration rather than using a const reference thus time and memory consuming.
          • your startsWith call, again, each iteration you retrieve the text from editSearch which is a waste of time, retrieve it once before starting the loop.
          • Why are you calling append m_testReportList.append once of each item in testReportIds ? You can do it in one call.
          • Why are you calling patientIds.append(patientIdStr); the same number of times you have testReportIds ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rashmi
            wrote on last edited by
            #5

            Can u suggest how to break foreach loop

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What do you mean by "break foreach loop" ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved