We are currently porting our embedded application from WinCE 6.0 / PXA320 to a newer system WinEC7 / iMX6S. Unfortunately we have performance issues on WinEC7, it is just half of the speed of the older system when writing files on the FlashDisk. Is there a reason for this? Can the performance be improved?
Here is our test code:
void FileSystemTest::test_createFiles()
{
const float LINE_NUMBERS = 10;
const int MIN_EXPONENT = 1;
const int MAX_EXPONENT = 5;
const std::string TEST_FILE_NAME = "testfile.txt";
std::string filePath("\\FlashDisk\\");
std::string file = filePath + "Duration.txt"; //store the
FILE *fp = fopen(file.c_str(), "w+"); //in milliseconds
fprintf(fp,"Create Files unit test (UtilitiesTest)\n");
fprintf(fp,"Write lines without closing file\n");
for(int exponent = MIN_EXPONENT; exponent < MAX_EXPONENT; exponent++)
{
DWORD startTime = GetTickCount();
int no_of_lines = (int)pow(LINE_NUMBERS, exponent);
// delete file if existing
PMT::FileSystem::deleteFile( filePath + TEST_FILE_NAME.c_str() );
test_createFile(filePath + TEST_FILE_NAME, no_of_lines, false);
DWORD endTime = GetTickCount();
DWORD duration = endTime - startTime; // duration in milliseconds
fprintf(fp,"Duration for %d lines: %d ms\n",no_of_lines, duration);
}
fprintf(fp,"Write lines with closing file\n");
for(int exponent = MIN_EXPONENT; exponent < MAX_EXPONENT; exponent++)
{
DWORD startTime = GetTickCount();
int no_of_lines = (int)pow(LINE_NUMBERS, exponent);
// delete file if existing
PMT::FileSystem::deleteFile( filePath + TEST_FILE_NAME.c_str() );
test_createFile(filePath + TEST_FILE_NAME, no_of_lines, true);
DWORD endTime = GetTickCount();
DWORD duration = endTime - startTime; // duration in milliseconds
fprintf(fp,"Duration for %d lines: %d ms\n",no_of_lines, duration);
}
// delete file
PMT::FileSystem::deleteFile( filePath + TEST_FILE_NAME.c_str() );
fclose(fp);
}
void FileSystemTest::test_createFile(const std::string fileName, const int lineNumbers, bool closeFileAfterLine)
{
FILE *fp = NULL;
if (!closeFileAfterLine)
{
fp = fopen(fileName.c_str() , "w");
}
for(int i = 0; i < lineNumbers; i++)
{
if (closeFileAfterLine)
{
fp = fopen(fileName.c_str() , "a");
}
CPPUNIT_ASSERT( fp != NULL );
fprintf(fp, "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n");
if (closeFileAfterLine)
{
fclose(fp);
}
}
if (!closeFileAfterLine)
{
fclose(fp);
}
}