|
Boost Users : |
Subject: Re: [Boost-users] why boost is so slow for file search?
From: Iain Denniston (iain.denniston_at_[hidden])
Date: 2012-06-13 13:32:47
I could be wrong but it looks like you might be doing a wide -> narrow
string conversion each time a string is added to the vector for the
boost version.
IIUC boost filesystem (v3 - the default) works with wide strings all the
time on Windows, however the accessor you are using always returns a
narrow string.
Try using "native()" instead of "string()" for getting the string from
the path and see if that makes things any better (obviously you will
also need to change the type of strings you use elsewhere).
HTH
Iain
On 12/06/2012 23:04, young wrote:
> 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