Boost logo

Boost Users :

Subject: [Boost-users] why boost is so slow for file search?
From: young (yqin_99_at_[hidden])
Date: 2012-06-12 18:04:36


I have 2 functions for read files list in one directory. One uses Win32 and
one uses boost:

void GetFilesWin32(std::string dir)
{
  std::vector<std::string> vFiles;
  std::string f = dir + "*.*";
  std::string file;
  WIN32_FIND_DATA findFileData;
  HANDLE h = FindFirstFile(f.c_str(), &findFileData);
  if(h != INVALID_HANDLE_VALUE)
  {
    do
    {
      if((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) !=
FILE_ATTRIBUTE_DIRECTORY)
      {
        file = findFileData.cFileName;
        vFiles.push_back( file);
      }
    } while( FindNextFile( h, &findFileData) != 0);
  }
  FindClose(h);
}

void GetFilesBoost(std::string dir)
{
  namespace fs = boost::filesystem;
  std::vector<std::string> vFiles;
  fs::path path(dir);
  fs::directory_iterator end_dir;
  for(fs::directory_iterator it(path); it != end_dir; it++)
  {
    if(!(fs::is_directory(it->status())))
    {
      vFiles.push_back(it->path().filename().string());
    }
  }
}

Boost takes 1.00 ms while Win32 taks 0.15 ms for same directory. Why?

--
View this message in context: http://boost.2283326.n4.nabble.com/why-boost-is-so-slow-for-file-search-tp4631199.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net