Skip to content

Commit

Permalink
Refs #5464. Reverts push of performance test.
Browse files Browse the repository at this point in the history
There's some linux path quirk that I'm not accounting for here, and I dont
have enough time to fix it today, so reverting.

This reverts commit 84c3e20.
This reverts commit c741880.
  • Loading branch information
PeterParker committed Jun 12, 2012
1 parent 84c3e20 commit 57c4dd2
Showing 1 changed file with 0 additions and 101 deletions.
101 changes: 0 additions & 101 deletions Code/Mantid/Framework/API/test/FileFinderTest.h
Expand Up @@ -8,9 +8,7 @@

#include <Poco/Path.h>
#include <Poco/File.h>
#include <boost/lexical_cast.hpp>

#include <stdio.h>
#include <fstream>

using namespace Mantid::Kernel;
Expand Down Expand Up @@ -293,103 +291,4 @@ class FileFinderTest: public CxxTest::TestSuite
Poco::File m_facFile;
};

class FileFinderTestPerformance : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static FileFinderTestPerformance *createSuite() { return new FileFinderTestPerformance(); }
static void destroySuite( FileFinderTestPerformance *suite ) { delete suite; }

FileFinderTestPerformance() :
m_oldDataSearchDirectories(), m_dirPath("../Testing/FileFinderTestPerformanceDummyData/"),
// Keeping these as low as possible so as to keep the time of the test down, but users with 70,000+ files
// in a single folder looking for a range of hundreds of files are not unheard of.
m_filesInDir(10000), m_filesToFind(100)
{
// Create some dummy TOSCA run files to use.
Poco::File dir(m_dirPath);
dir.createDirectory();

for( size_t run = 0; run < m_filesInDir; ++run )
{
std::stringstream filename;
filename << m_dirPath << "TSC";
pad(filename, run);
filename << ".raw";

{
// Hoping for some speed increase from this (assuming no RVO optimisation
// when using filename.str().c_str() ...):
const std::string& tmp = filename.str();
const char* cstr = tmp.c_str();

// Shun use of Poco, which is slower.
FILE * pFile;
pFile = fopen (cstr , "w");
if (pFile != NULL)
{
fclose (pFile);
}
}
}

// Set TOSCA as default instrument.
Mantid::Kernel::ConfigService::Instance().setString("default.instrument", "TSC");

// Add dummy directory to search path, saving old search paths to be put back later.
m_oldDataSearchDirectories = Mantid::Kernel::ConfigService::Instance().getString("datasearch.directories");
Mantid::Kernel::ConfigService::Instance().setString("datasearch.directories", dir.path());
}

~FileFinderTestPerformance()
{
// Put back the old search paths.
Mantid::Kernel::ConfigService::Instance().setString("datasearch.directories", m_oldDataSearchDirectories);

// Destroy dummy folder and files.
// Use Poco here so removing works on multiple platforms. Recursive .remove(true) also means we dont have to generate
// the filenames for a second time.
Poco::File dir(m_dirPath);
dir.remove(true);
}

void test_largeDirectoryOfFiles()
{
std::vector<std::string> files;
std::stringstream range;
range << (m_filesInDir - m_filesToFind) << "-" << (m_filesInDir - 1);
TS_ASSERT_THROWS_NOTHING( files = FileFinder::Instance().findRuns(range.str().c_str()) );
TS_ASSERT( files.size() == m_filesToFind );
}

private:

/**
* Pad the given stringstream with zeros from a lookup, then add the run number.
*/
void pad(std::stringstream & stream, size_t run)
{
if( run < 10 )
stream << "0000" << run;
else if( run < 100 )
stream << "000" << run;
else if( run < 1000 )
stream << "00" << run;
else if( run < 10000 )
stream << "0" << run;
else
stream << run;
}

// Temp storage.
std::string m_oldDataSearchDirectories;
// Path to directory where dummy files will be created.
std::string m_dirPath;
// Number of dummy files to create.
size_t m_filesInDir;
// Number of files to find.
size_t m_filesToFind;
};

#endif /*FILEFINDERTEST_H_*/

0 comments on commit 57c4dd2

Please sign in to comment.