MojErr MojDbPerfCreateTest::run() { MojErr err = file.open(CreateTestFileName, MOJ_O_RDWR | MOJ_O_CREAT | MOJ_O_TRUNC, MOJ_S_IRUSR | MOJ_S_IWUSR); MojString buf; err = buf.format("MojoDb Create Performance Test,,,,,\n\nOperation,Kind,Total Time,Time Per Iteration,Time Per Object\n"); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); err = testCreate(); MojTestErrCheck(err); allTestsTime += totalTestTime; err = MojPrintF("\n\n TOTAL TEST TIME: %llu nanoseconds. | %10.3f seconds.\n\n", totalTestTime, totalTestTime / 1000000000.0f); MojTestErrCheck(err); err = MojPrintF("\n-------\n"); MojTestErrCheck(err); err = buf.format("\n\nTOTAL TEST TIME,,%llu,,,", totalTestTime); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); err = file.close(); MojTestErrCheck(err); return MojErrNone; }
MojErr MojDbPerfUpdateTest::updateObjsViaPut(MojDb& db, const MojChar* kindId, MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64)) { // register all the kinds MojTime time; MojErr err = putKinds(db, time); MojTestErrCheck(err); // put objects using createFn MojObject objs; err = putObjs(db, kindId, numInsertForPut, createFn, objs); MojTestErrCheck(err); MojObject midObj; bool found = objs.at(numInsertForPut/2, midObj); MojTestAssert(found); MojTime objTime; err = putObj(db, midObj, objTime); MojTestErrCheck(err); MojUInt64 putTime = objTime.microsecs(); err = MojPrintF("\n -------------------- \n"); MojTestErrCheck(err); err = MojPrintF(" putting single object - index %llu - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/2, kindId, numPutIterations, putTime); MojTestErrCheck(err); err = MojPrintF(" time per put: %llu microsecs", (putTime) / (numPutIterations)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); MojString buf; err = buf.format("Put single object - index %llu - %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/2, numPutIterations, kindId, putTime, putTime/numPutIterations, putTime/(1*numPutIterations)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); MojTime batchTime; MojObject::ArrayIterator beginArr; err = objs.arrayBegin(beginArr); MojErrCheck(err); err = batchPutObj(db, beginArr, beginArr + (numInsertForPut / 10), batchTime); putTime = batchTime.microsecs(); MojTestErrCheck(err); err = MojPrintF(" putting batch - %llu objects - of kind %s %llu times took: %llu microsecs\n", numInsertForPut/10, kindId, numBatchPutIterations, putTime); MojTestErrCheck(err); err = MojPrintF(" time per batch put: %llu microsecs\n", (putTime) / (numBatchPutIterations)); MojTestErrCheck(err); err = MojPrintF(" time per object: %llu microsecs", (putTime) / (numInsertForPut/10 * numBatchPutIterations)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); err = buf.format("Batch put %llu objects %llu times,%s,%llu,%llu,%llu,\n", numInsertForPut/10, numBatchPutIterations, kindId, putTime, putTime/numBatchPutIterations, putTime/(numInsertForPut/10*numBatchPutIterations)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); return MojErrNone; }
// This is called by tester in Simple.cpp void TestFilter::audioFileTest(float **audioFile, const int &fileLength, const int &numChannels) { if (!_iWhichFilter) { for ( int i=0; i<numChannels; i++ ) { testFIR -> filterProcess(audioFile[i], fileLength, i); } fileWrite(audioFile, "FIRAudioFileTestResult.txt", fileLength, numChannels); } else { for ( int i=0; i<numChannels; i++ ) { testIIR -> filterProcess(audioFile[i], fileLength, i); } fileWrite(audioFile, "IIRAudioFileTestResult.txt", fileLength, numChannels); } }
// This is called by testee1 and testee2 in Simple.cpp void TestFilter::zeroInputTest() { initTestSignal(); if( !_iWhichFilter ) { testFIR->filterProcess( _fTestSignal, 100, 0); fileWrite( _fTestSignal, "FIRZeroInputTest.txt", 100 ); } else { testIIR->filterProcess( _fTestSignal, 100, 0); fileWrite( _fTestSignal, "IIRZeroInputTest.txt", 100 ); } }
bool CMake::writeWorkspace() { // open output file fileOpen("CMakeLists.txt"); fileWrite("cmake_minimum_required(VERSION 2.8.1)\n\n"); // set configurations fileWrite(String("set(CMAKE_CONFIGURATION_TYPES ") + join(configurations) + ")\n"); fileWrite("set(CMAKE_CONFIGURATION_TYPES \"${CMAKE_CONFIGURATION_TYPES}\" CACHE STRING \"Supported configuration types\" FORCE)\n\n"); // set default configuration if(!configurations.isEmpty()) { const String& defaultConfigName = configurations.getFirst()->data; fileWrite(String("if(CMAKE_BUILD_TYPE STREQUAL \"\")\n")); fileWrite(String("set(CMAKE_BUILD_TYPE \"") + defaultConfigName + "\")\n"); fileWrite(String("endif()\n\n")); } // set solution name fileWrite(String("project(") + workspaceName + ")\n\n"); // write project list for(const Map<String, Project>::Node* i = projects.getFirst(); i; i = i->getNext()) fileWrite(String("add_subdirectory(.CMake/") + i->key + ")\n"); fileClose(); return true; }
MojErr MojDbPerfUpdateTest::testMerge(MojDb& db) { MojString buf; MojErr err = buf.format("\nUPDATE VIA MERGE,,,,,\n"); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfSmKindId, &MojDbPerfTest::createSmallObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfMedKindId, &MojDbPerfTest::createMedObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfLgKindId, &MojDbPerfTest::createLargeObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfMedNestedKindId, &MojDbPerfTest::createMedNestedObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfLgNestedKindId, &MojDbPerfTest::createLargeNestedObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfMedArrayKindId, &MojDbPerfTest::createMedArrayObj); MojTestErrCheck(err); err = updateObjsViaMerge(db, MojPerfLgArrayKindId, &MojDbPerfTest::createLargeArrayObj); MojTestErrCheck(err); return MojErrNone; }
size_t FileStream::write(const uint8_t *buffer, size_t size) { if (!fileExist()) return 0; bool result = fileSeek(handle, 0, eSO_FileEnd); return fileWrite(handle, buffer, size); }
MojErr MojDbPerfUpdateTest::testUpdateKind(MojDb& db) { MojString buf; MojErr err = buf.format("\nUPDATE KIND,,,,,\n"); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); err = updateKind(db, MojPerfSmKindId, MojPerfSmKindStr, MojPerfSmKindExtraIndex, &MojDbPerfTest::createSmallObj); MojTestErrCheck(err); err = updateKind(db, MojPerfMedKindId, MojPerfMedKindStr, MojPerfMedKindExtraIndex, &MojDbPerfTest::createMedObj); MojTestErrCheck(err); err = updateKind(db, MojPerfLgKindId, MojPerfLgKindStr, MojPerfLgKindExtraIndex, &MojDbPerfTest::createLargeObj); MojTestErrCheck(err); err = updateKind(db, MojPerfMedNestedKindId, MojPerfMedNestedKindStr, MojPerfMedNestedKindExtraIndex, &MojDbPerfTest::createMedNestedObj); MojTestErrCheck(err); err = updateKind(db, MojPerfLgNestedKindId, MojPerfLgNestedKindStr, MojPerfLgNestedKindExtraIndex, &MojDbPerfTest::createLargeNestedObj); MojTestErrCheck(err); err = updateKind(db, MojPerfMedArrayKindId, MojPerfMedArrayKindStr, MojPerfMedArrayKindExtraIndex, &MojDbPerfTest::createMedArrayObj); MojTestErrCheck(err); err = updateKind(db, MojPerfLgArrayKindId, MojPerfLgArrayKindStr, MojPerfLgArrayKindExtraIndex, &MojDbPerfTest::createLargeArrayObj); MojTestErrCheck(err); return MojErrNone; }
void HttpClient::writeRawData(pbuf* buf, int startPos) { switch (mode) { case eHCM_String: { responseStringData += NetUtils::pbufStrCopy(buf, startPos, buf->tot_len - startPos); break; } case eHCM_File: { pbuf *cur = buf; while (cur != NULL && cur->len > 0 && !writeError) { char* ptr = (char*) cur->payload + startPos; int len = cur->len - startPos; int res = fileWrite(saveFile, ptr, len); writeError |= (res < 0); cur = cur->next; startPos = 0; } if (writeError) close(); } } }
// This is called by testee1 and testee2 in Simple.cpp void TestFilter::unitImpulseTest() { initTestSignal(); //unit impulse _fTestSignal[0] = 1.0f; if( !_iWhichFilter ) { testFIR->filterProcess( _fTestSignal, 100, 0); fileWrite( _fTestSignal, "FIRUnitImpulseFilter.txt", 100 ); } else { testIIR->filterProcess( _fTestSignal, 100, 0 ); fileWrite( _fTestSignal, "IIRUnitImpulseFilter.txt", 100 ); } }
void Grafo::impimir_color(std::string fileTestWrite){ std::ofstream fileWrite (fileTestWrite.c_str(), std::ofstream::app); for(Vertice& v : vertices_) { fileWrite << v.dame_color() << " "; } fileWrite << std::endl; }
bool fileWrite(const void *buffer, const char *path, u32 size) { FIL file; FRESULT result; switch(f_open(&file, path, FA_WRITE | FA_OPEN_ALWAYS)) { case FR_OK: { unsigned int written; result = f_write(&file, buffer, size, &written); if(result == FR_OK) result = f_truncate(&file); result |= f_close(&file); return result == FR_OK && (u32)written == size; } case FR_NO_PATH: for(u32 i = 1; path[i] != 0; i++) if(path[i] == '/') { char folder[i + 1]; memcpy(folder, path, i); folder[i] = 0; result = f_mkdir(folder); } return result == FR_OK && fileWrite(buffer, path, size); default: return false; } }
MojErr MojDbPerfUpdateTest::updateKind(MojDb& db, const MojChar* kindId, const MojChar* kindJson, const MojChar* extraIdxJson, MojErr (MojDbPerfTest::*createFn) (MojObject&, MojUInt64)) { // register all the kinds MojTime time; MojErr err = putKinds(db, time); MojTestErrCheck(err); // put objects using createFn MojObject objs; err = putObjs(db, kindId, numObjectsBeforeUpdateKind, createFn, objs); MojTestErrCheck(err); // add an index MojObject kindObj; err = kindObj.fromJson(kindJson); MojTestErrCheck(err); MojObject indexes; kindObj.get(_T("indexes"), indexes); MojTestErrCheck(err); MojObject extraIdx; err = extraIdx.fromJson(extraIdxJson); MojTestErrCheck(err); indexes.push(extraIdx); err = kindObj.put(_T("indexes"), indexes); MojTestErrCheck(err); MojTime addIndexTime; MojTime dropIndexTime; err = timeUpdateKind(db, kindJson, kindObj, addIndexTime, dropIndexTime); MojTestErrCheck(err); MojUInt64 addTime = addIndexTime.microsecs(); MojUInt64 dropTime = dropIndexTime.microsecs(); err = MojPrintF("\n -------------------- \n"); MojTestErrCheck(err); err = MojPrintF(" updating kind %s - adding index %s %llu times took: %llu microsecs\n", kindId, extraIdxJson, numUpdateKindIterations, addTime); MojTestErrCheck(err); err = MojPrintF(" time per add/reindex: %llu microsecs\n", (addTime) / (numUpdateKindIterations)); MojTestErrCheck(err); err = MojPrintF(" updating kind %s - dropping index %s %llu times took: %llu microsecs\n", kindId, extraIdxJson, numUpdateKindIterations, dropTime); MojTestErrCheck(err); err = MojPrintF(" time per drop: %llu microsecs", (dropTime) / (numUpdateKindIterations)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); MojString buf; err = buf.format("Updating kind %s - adding index %s %llu times,%s,%llu,%llu,%llu,\nUpdating kind %s - dropping index %s %llu times,%s,%llu,%llu,%llu,\n", kindId, extraIdxJson, numUpdateKindIterations, kindId, addTime, addTime/numUpdateKindIterations, addTime/(1*numUpdateKindIterations), kindId, extraIdxJson, numUpdateKindIterations, kindId, dropTime, dropTime/numUpdateKindIterations, dropTime/(1*numUpdateKindIterations)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); return MojErrNone; }
MojErr MojDbPerfUpdateTest::run() { MojErr err = file.open(UpdateTestFileName, MOJ_O_RDWR | MOJ_O_CREAT | MOJ_O_TRUNC, MOJ_S_IRUSR | MOJ_S_IWUSR); MojTestErrCheck(err); MojString buf; err = buf.format("MojoDb Update Performance Test,,,,,\n\nOperation,Kind,Total Time,Time Per Iteration,Time Per Object\n"); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); MojDb db; err = db.open(MojDbTestDir); MojTestErrCheck(err); err = testPut(db); MojTestErrCheck(err); err = testMerge(db); MojTestErrCheck(err); err = testUpdateKind(db); MojTestErrCheck(err); err = MojPrintF("\n\n TOTAL TEST TIME: %llu microseconds\n\n", totalTestTime.microsecs()); MojTestErrCheck(err); err = MojPrintF("\n-------\n"); MojTestErrCheck(err); err = buf.format("\n\nTOTAL TEST TIME,,%llu,,,", totalTestTime.microsecs()); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); err = db.close(); MojTestErrCheck(err); err = file.close(); MojTestErrCheck(err); return MojErrNone; }
bool FileOut::done() { Q_ASSERT(!isDone); if (name.isEmpty()) return false; isDone = true; bool fileEqual = false; QFile fileRead(name); QFileInfo info(fileRead); stream.flush(); QByteArray original; if (info.exists() && (diff || (info.size() == tmp.size()))) { if (!fileRead.open(QIODevice::ReadOnly)) { ReportHandler::warning(QString("failed to open file '%1' for reading") .arg(fileRead.fileName())); return false; } original = fileRead.readAll(); fileRead.close(); fileEqual = (original == tmp); } if (!fileEqual) { if (!FileOut::dummy) { QDir dir(info.absolutePath()); if (!dir.mkpath(dir.absolutePath())) { ReportHandler::warning(QString("unable to create directory '%1'") .arg(dir.absolutePath())); return false; } QFile fileWrite(name); if (!fileWrite.open(QIODevice::WriteOnly)) { ReportHandler::warning(QString("failed to open file '%1' for writing") .arg(fileWrite.fileName())); return false; } QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); stream.setDevice(&fileWrite); stream << tmp; } if (diff) { std::printf("%sFile: %s%s\n", colorInfo, qPrintable(name), colorReset); ::diff(original.split('\n'), tmp.split('\n')); std::printf("\n"); } return true; } return false; }
void Functionality::updateFile() { unsigned i; ofstream fileWrite("EventStorage.txt"); fileWrite<<"High Priority Event(s) :-\n"; for(i = 0; i < highPriority.size(); i++) fileWrite << eventConvert(highPriority[i]) << "\n"; fileWrite << "\n"; fileWrite << "Normal Priority Event(s) :-\n"; for(i = 0; i < normalPriority.size(); i++) fileWrite << eventConvert(normalPriority[i]) << "\n"; fileWrite.close(); }
void writeConfig(bool isConfigOptions) { //If the configuration is different from previously, overwrite it. if(needConfig != CREATE_CONFIGURATION && ((isConfigOptions && configData.config == oldConfig.config && configData.multiConfig == oldConfig.multiConfig) || (!isConfigOptions && configData.bootConfig == oldConfig.bootConfig))) return; if(needConfig == CREATE_CONFIGURATION) { memcpy(configData.magic, "CONF", 4); configData.formatVersionMajor = CONFIG_VERSIONMAJOR; configData.formatVersionMinor = CONFIG_VERSIONMINOR; needConfig = MODIFY_CONFIGURATION; } if(!fileWrite(&configData, CONFIG_FILE, sizeof(CfgData))) error("Error writing the configuration file"); }
void Functionality::notificationFile() { int eventCount = 0; ofstream fileWrite("ReminderStorage.txt"); unsigned i; unsigned j; vector<EventStorage> tempVector; for(i=0;i<2;i++) { if(i==0) tempVector=highPriority; else tempVector=normalPriority; for(j=0;j<tempVector.size() && eventCount <10 ;j++) { if(tempVector[j].getDoneFlag()==0) { fileWrite<<eventCount+1<<". "; if(tempVector[j].getTitle().size()!=0) fileWrite<<"<"<<tempVector[j].getTitle()<<">"<<" "; else fileWrite<<"< > "; if(tempVector[j].getDate()!="00-00-0000") fileWrite<<"<"<<tempVector[j].getDate()<<">"<<" "; else fileWrite<<"< > "; if(tempVector[j].getTime()!="25:00") fileWrite<<"<"<<tempVector[j].getTime()<<">"<<" "; else fileWrite<<"< > "; fileWrite<<"<"<<tempVector[j].getCode()<<">"; if(i==0) fileWrite<<"\\12"; else fileWrite<<"\\10"; fileWrite<<"\n"; eventCount++; } } } if(eventCount==0) fileWrite<<"No Event has been created yet\\15"; fileWrite.close(); }
void keyboardSpecial(int key, int x, int y) { switch(key) { case GLUT_KEY_F1: resetField(); printf("Field cleared!\n"); break; case GLUT_KEY_F2: fileWrite(); printf("Field saved!\n"); break; case GLUT_KEY_F3: fileRead(); printf("Field loaded!\n"); break; } }
void tests2(){ Huffman h; Huffman_init(&h); int size; unsigned char *data = fileRead("LICENSE",&size); Huffman_add_data_block(&h,data,size); Huffman_apply(&h); Huffman_compress_data_to_file(&h,"LICENSE.hff"); Huffman_free(&h); Huffman_init(&h); Huffman_file_decompress(&h,"LICENSE.hff"); fileWrite("Decompressed LICENSE.txt",h.uc_data[0],h.uc_sizes[0]); }
int main(int argc, char **argv) { char *fout, *point; seclist=calloc(1, sizeof(Section)); if(argc<2 || argc>3) usage(); if(argc==2){ fout=(char*)strdup(argv[1]); point=strchr(fout, '.'); if(point == NULL) pexit("Couldn generate output filename - no . in input file\n", argv[1]); strcpy(point, ".h"); }else fout=argv[2]; if(!strcmp(fout, argv[1])){ printf("input and output files have the same name - exiting\n"); exit(1); } fileWrite(fileRead(argv[1]), fout); return(0); }
MojErr MojDbPerfCreateTest::testBatchInsertLgArrayObj(MojDb& db, const MojChar* kindId) { // register all the kinds again MojTime time; MojErr err = putKinds(db, time); MojTestErrCheck(err); // time put with large array objects (20 properties + 2 arrays of 5 elements each) MojTime batchLgArrayObjTime = 0; for (int i = 0; i < numRepetitions; i++) { err = putLargeArrayObj(db, kindId, batchLgArrayObjTime); MojTestErrCheck(err); MojDbQuery q; err = q.from(kindId); MojTestErrCheck(err); MojUInt32 count = 0; err = db.del(q, count); MojTestErrCheck(err); } MojUInt64 putTime = batchLgArrayObjTime.microsecs(); err = MojPrintF("\n -------------------- \n"); MojTestErrCheck(err); err = MojPrintF(" time to batch put %llu %s objects %d times: %llu microsecs\n", numInsert, kindId, numRepetitions, putTime); MojTestErrCheck(err); err = MojPrintF(" time per batch: %llu microsecs", (putTime) / (numRepetitions)); MojTestErrCheck(err); err = MojPrintF(" time per object: %llu microsecs", (putTime) / (numInsert * numRepetitions)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); MojString buf; err = buf.format("batch put %llu objects %d times,%s,%llu,%llu,%llu,\n", numInsert, numRepetitions, kindId, putTime, putTime/numRepetitions, putTime / (numInsert * numRepetitions)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); return MojErrNone; }
MojErr MojDbPerfCreateTest::testInsertMedArrayObj(MojDb& db, const MojChar* kindId) { // register all the kinds again MojTime time; MojErr err = putKinds(db, time); MojTestErrCheck(err); // time put with med array objects (10 properties + 1 array of 5 elements) MojTime medArrayObjTime; for (int i = 0; i < numRepetitions; i++) { err = putMedArrayObj(db, kindId, medArrayObjTime); MojTestErrCheck(err); MojDbQuery q; err = q.from(kindId); MojTestErrCheck(err); MojUInt32 count = 0; err = db.del(q, count, MojDb::FlagPurge); MojTestErrCheck(err); } MojUInt64 putTime = medArrayObjTime.microsecs(); err = MojPrintF("\n -------------------- \n"); MojTestErrCheck(err); err = MojPrintF(" time to put %llu %s objects %d times: %llu microsecs\n", numInsert, kindId, numRepetitions, putTime); MojTestErrCheck(err); err = MojPrintF(" time per object: %llu microsecs", (putTime) / (numInsert * numRepetitions)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); MojString buf; err = buf.format("put %llu objects %d times,%s,%llu,%llu,%llu,\n", numInsert, numRepetitions, kindId, putTime, putTime/numRepetitions, putTime / (numInsert * numRepetitions)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); return MojErrNone; }
void error(const char *fmt, ...) { char buf[DRAW_MAX_FORMATTED_STRING_SIZE + 1]; va_list args; va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); if(!isFirmlaunch) { initScreens(); drawString(true, 10, 10, COLOR_RED, "An error has occurred:"); u32 posY = drawString(true, 10, 30, COLOR_WHITE, buf); drawString(true, 10, posY + 2 * SPACING_Y, COLOR_WHITE, "Press any button to shutdown"); waitInput(false); } else fileWrite(buf, "firmlauncherror.txt", strlen(buf)); mcuPowerOff(); }
int _rsFileWrite (rsComm_t *rsComm, fileWriteInp_t *fileWriteInp, bytesBuf_t *fileWriteInpBBuf) { int retVal; /* XXXX need to check resource permission and vault permission * when RCAT is available */ retVal = fileWrite (FileDesc[fileWriteInp->fileInx].fileType, rsComm, FileDesc[fileWriteInp->fileInx].fd, fileWriteInpBBuf->buf, fileWriteInp->len); if (retVal < 0) { rodsLog (LOG_NOTICE, "_rsFileWrite: fileWrite for %s, status = %d", FileDesc[fileWriteInp->fileInx].fileName, retVal); return (retVal); } return (retVal); }
MojErr MojDbPerfCreateTest::testInsertLgNestedObj(MojDb& db, const MojChar* kindId) { // register all the kinds again MojUInt64 time = 0; MojErr err = putKinds(db, time); MojTestErrCheck(err); // time put with large nested objects (3 levels of nesting, 20 properties) MojUInt64 largeNestedObjTime = 0; for (int i = 0; i < numRepetitions; i++) { err = putLargeNestedObj(db, kindId, largeNestedObjTime); MojTestErrCheck(err); MojDbQuery q; err = q.from(kindId); MojTestErrCheck(err); MojUInt32 count = 0; err = db.del(q, count, MojDb::FlagPurge); MojTestErrCheck(err); } err = MojPrintF("\n -------------------- \n"); MojTestErrCheck(err); err = MojPrintF(" time to put %llu %s nested objects %d times: %llu nanosecs\n", numInsert, kindId, numRepetitions, largeNestedObjTime); MojTestErrCheck(err); err = MojPrintF(" time per object: %llu nanosecs", (largeNestedObjTime) / (numInsert * numRepetitions)); MojTestErrCheck(err); err = MojPrintF("\n\n"); MojTestErrCheck(err); MojString buf; err = buf.format("put %llu objects %d times,%s,%llu,%llu,%llu,\n", numInsert, numRepetitions, kindId, largeNestedObjTime, largeNestedObjTime/numRepetitions, largeNestedObjTime / (numInsert * numRepetitions)); MojTestErrCheck(err); err = fileWrite(file, buf); MojTestErrCheck(err); return MojErrNone; }
// function that writes current data int File::fileWrite() { fileWrite(m_fN, m_fD); return 0; }
// protected function to initiate G appendix data from A NEEDS BREAKING DOWN INTO SUB FUNC int File::initFile() { // going through all known files getting relevant data // this could have been multithreaded // setting array with file paths I dont want to put it here, // but for the sake of not making things any more convoluted // I know its horrible to do it like this but its temporary. char* relativeFile[] = { "..\\..\\..\\ProgramResources\\G Appendix\\G A-Z.txt", // first is destination "..\\..\\..\\ProgramResources\\A Appendix\\A-B.txt", // A-B "..\\..\\..\\ProgramResources\\A Appendix\\C.txt", // C "..\\..\\..\\ProgramResources\\A Appendix\\D-F.txt", // D-F "..\\..\\..\\ProgramResources\\A Appendix\\G-K.txt", // G-K "..\\..\\..\\ProgramResources\\A Appendix\\L-O.txt", // L-O "..\\..\\..\\ProgramResources\\A Appendix\\P-R.txt", // P-R "..\\..\\..\\ProgramResources\\A Appendix\\S.txt", // S "..\\..\\..\\ProgramResources\\A Appendix\\T-Z.txt" // T-Z }; // creating temporary list std::vector<std::vector<std::string> > list; // for loop that cycles through relativeFile[] by calculating size for (int i = 1; i < sizeof(relativeFile)/sizeof(relativeFile[0]); i++) { // for each file path: std::cout << "init, " << relativeFile[i] << ", now." << std::endl; // set file name to m_fN = relativeFile[i]; // read file fileRead(); // creating intermediate containers std::string lastWord = ""; std::vector<std::string> wordList; std::vector<std::string> numberList; // for each cue: for (int c = 0; c < m_fD.size(); c++) { //std::cout << (m_fD[c][0])[0] << std::endl; if ((m_fD[c][0])[0] != '<') { // if this item exists already // by checking the last item if (m_fD[c][0] == lastWord) { //std::cout << m_fD[c][1] << std::endl; wordList.push_back(m_fD[c][1]); numberList.push_back(m_fD[c][4]); } else // only happens if a different word so start of a new sequence { // check to see if previous sequence is not empty if (wordList.size() > 0 && numberList.size() > 0) { // publish last sequence now that we know its finished // and checking to get rid of CUE line if (wordList[0] != "CUE") { list.push_back(wordList); list.push_back(numberList); } // clear last sequence wordList.clear(); numberList.clear(); } // start new sequence lastWord = m_fD[c][0]; std::cout << lastWord << std::endl; // add current position data into new sequence wordList.push_back(lastWord); wordList.push_back(m_fD[c][1]); numberList.push_back(m_fD[c][3]); numberList.push_back(m_fD[c][4]); } } } // check to see if last sequence is not empty if (wordList.size() > 0 && numberList.size() > 0) { // publish last sequence now that we know its finished list.push_back(wordList); list.push_back(numberList); // clear last sequence wordList.clear(); numberList.clear(); } } // m_fN = destination m_fN = relativeFile[0]; // m_fD = list // not gonna do it because its inefficent since its non pointer // file write fileWrite(m_fN, list); return 0; }
// =-=-=-=-=-=-=- // local implementation of put int _rsFilePut( rsComm_t* _comm, fileOpenInp_t* _put_inp, bytesBuf_t* _put_bbuf, rodsServerHost_t* _server_host ) { int fd = 0; // =-=-=-=-=-=-=- // NOTE:: this test does not seem to work for i86 solaris if ( ( _put_inp->otherFlags & FORCE_FLAG ) != 0 ) { // =-=-=-=-=-=-=- // create one if it does not exist */ _put_inp->flags |= O_CREAT; fd = _rsFileOpen( _comm, _put_inp ); } else { fd = _rsFileCreate( _comm, _put_inp, _server_host ); } // else // =-=-=-=-=-=-=- // log, error if any if ( fd < 0 ) { if ( getErrno( fd ) == EEXIST ) { rodsLog( LOG_DEBUG1, "_rsFilePut: filePut for %s, status = %d", _put_inp->fileName, fd ); } else if ( fd != DIRECT_ARCHIVE_ACCESS ) { rodsLog( LOG_DEBUG, "_rsFilePut: filePut for %s, status = %d", _put_inp->fileName, fd ); } return ( fd ); } // =-=-=-=-=-=-=- // call write for resource plugin irods::file_object_ptr file_obj( new irods::file_object( _comm, _put_inp->objPath, _put_inp->fileName, _put_inp->resc_hier_, fd, 0, 0 ) ); file_obj->in_pdmo( _put_inp->in_pdmo ); file_obj->cond_input( _put_inp->condInput ); irods::error write_err = fileWrite( _comm, file_obj, _put_bbuf->buf, _put_bbuf->len ); int write_code = write_err.code(); // =-=-=-=-=-=-=- // log errors, if any if ( write_code != _put_bbuf->len ) { if ( write_code >= 0 ) { std::stringstream msg; msg << "fileWrite failed for ["; msg << _put_inp->fileName; msg << "] towrite ["; msg << _put_bbuf->len; msg << "] written ["; msg << write_code << "]"; irods::error err = PASSMSG( msg.str(), write_err ); irods::log( err ); write_code = SYS_COPY_LEN_ERR; } else { std::stringstream msg; msg << "fileWrite failed for ["; msg << _put_inp->fileName; msg << "]"; irods::error err = PASSMSG( msg.str(), write_err ); irods::log( err ); } } // =-=-=-=-=-=-=- // close up after ourselves irods::error close_err = fileClose( _comm, file_obj ); if ( !close_err.ok() ) { irods::error err = PASSMSG( "error on close", close_err ); irods::log( err ); } // =-=-=-=-=-=-=- // return 'write_err code' as this includes this implementation // assumes we are returning the size of the file 'put' via fileWrite return write_code; } // _rsFilePut
bool CMake::writeProject(const String& targetName, Project& project) { Directory::create(String(".CMake/") + targetName); fileOpen(String(".CMake/") + targetName + "/CMakeLists.txt"); fileWrite("cmake_policy(SET CMP0015 NEW)\n\n"); for(const Map<String, ProjectConfiguration>::Node* i = project.configurations.getFirst(); i; i = i->getNext()) { const String& configName = i->key; const ProjectConfiguration& config = i->data; const Target& target = *config.target; if(i == project.configurations.getFirst()) fileWrite(String("if(CMAKE_BUILD_TYPE STREQUAL \"") + configName +"\")\n"); else fileWrite(String("elseif(CMAKE_BUILD_TYPE STREQUAL \"") + configName +"\")\n"); if(!target.includePaths.isEmpty()) fileWrite(String("include_directories(") + joinPaths(target.includePaths) + ")\n"); if(!target.libPaths.isEmpty()) fileWrite(String("link_directories(") + joinPaths(target.libPaths) + ")\n"); List<String> customBuildOutput; for(const List<const File*>::Node* i = config.customBuildFiles.getFirst(); i; i = i->getNext()) { const File& file = *i->data; fileWrite("add_custom_command(\n"); fileWrite(String(" OUTPUT ") + joinPaths(file.output, true) + "\n"); Map<String, void*> outputDirs; for(const List<String>::Node* i = file.output.getFirst(); i; i = i->getNext()) { String dir = ::File::getDirname(i->data); if(dir != "." && !outputDirs.find(dir)) outputDirs.append(dir); } for(Map<String, void*>::Node* i = outputDirs.getFirst(); i; i = i->getNext()) fileWrite(String(" COMMAND ${CMAKE_COMMAND} -E make_directory ") + translatePath(i->key, true) + "\n"); for(const List<String>::Node* i = file.command.getFirst(); i; i = i->getNext()) fileWrite(String(" COMMAND ") + i->data + "\n"); fileWrite(String(" DEPENDS ") + joinPaths(file.input) + "\n"); fileWrite(" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..\n"); if(!file.message.isEmpty()) fileWrite(String(" COMMENT \"") + file.message.getFirst()->data + "\"\n"); fileWrite(" )\n"); for(const List<String>::Node* i = file.output.getFirst(); i; i = i->getNext()) customBuildOutput.append(i->data); } if(config.type == ProjectConfiguration::applicationType) fileWrite(String("add_executable(") + targetName + " " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n"); else if(config.type == ProjectConfiguration::dynamicLibraryType) fileWrite(String("add_library(") + targetName + " SHARED " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n"); else if(config.type == ProjectConfiguration::staticLibraryType) fileWrite(String("add_library(") + targetName + " STATIC " + joinPaths(config.sourceFiles) + " " + joinPaths(customBuildOutput, true) + ")\n"); else if(config.type == ProjectConfiguration::customTargetType) { if(!target.output.isEmpty() && !target.command.isEmpty()) { fileWrite("add_custom_command(\n"); fileWrite(String(" OUTPUT ") + joinPaths(target.output, true) + "\n"); Map<String, void*> outputDirs; for(const List<String>::Node* i = target.output.getFirst(); i; i = i->getNext()) { String dir = ::File::getDirname(i->data); if(dir != "." && !outputDirs.find(dir)) outputDirs.append(dir); customBuildOutput.append(i->data); } for(Map<String, void*>::Node* i = outputDirs.getFirst(); i; i = i->getNext()) fileWrite(String(" COMMAND ${CMAKE_COMMAND} -E make_directory ") + translatePath(i->key, true) + "\n"); for(const List<String>::Node* i = target.command.getFirst(); i; i = i->getNext()) fileWrite(String(" COMMAND ") + i->data + "\n"); fileWrite(String(" DEPENDS ") + joinPaths(target.input) + "\n"); fileWrite(" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..\n"); if(!target.message.isEmpty()) fileWrite(String(" COMMENT \"") + target.message.getFirst()->data + "\"\n"); fileWrite(" )\n"); } fileWrite(String("add_custom_target(") + targetName + " ALL\n"); fileWrite(String(" DEPENDS ") + joinPaths(customBuildOutput, true) + "\n"); fileWrite(String(" SOURCES ") + joinPaths(config.sourceFiles) + "\n"); fileWrite(" )\n"); } /* if(!config.libs.isEmpty()) { List<String> libs; for(const List<Library>::Node* i = config.libs.getFirst(); i; i = i->getNext()) { const Library& lib = i->data; if(lib.type == Library::localType) libs.append(lib.name); else { fileWrite(String("find_library(") + lib.name + "_LIBRARY " + lib.name + " PATHS " + join(target.libPaths) + ")\n"); libs.append(String("${") + lib.name + "_LIBRARY}"); } } fileWrite(String("target_link_libraries(") + targetName + " " + join(libs) + ")\n"); } */ if(!config.libs.isEmpty()) { List<String> libs; for(const List<Library>::Node* i = config.libs.getFirst(); i; i = i->getNext()) libs.append(i->data.name); fileWrite(String("target_link_libraries(") + targetName + " " + join(libs) + ")\n"); } if(!target.cppCompiler.isEmpty()) { String cppCompiler; for(const List<String>::Node* i = target.cppCompiler.getFirst(); i; i = i->getNext()) { const String& word = i->data; size_t sep; if(word.find('=', sep)) fileWrite(String("set(ENV{") + word.substr(0, sep) + "} \"" + word.substr(sep + 1) + "\")\n"); else { cppCompiler = word; break; } } if(!cppCompiler.isEmpty()) { if(!::File::isPathAbsolute(cppCompiler) && ::File::exists(cppCompiler)) fileWrite(String("set(CMAKE_CXX_COMPILER \"${CMAKE_CURRENT_SOURCE_DIR}/../../") + cppCompiler + "\")\n"); else fileWrite(String("set(CMAKE_CXX_COMPILER \"") + cppCompiler + "\")\n"); } } if(!target.cCompiler.isEmpty()) { String cCompiler; for(const List<String>::Node* i = target.cCompiler.getFirst(); i; i = i->getNext()) { const String& word = i->data; size_t sep; if(word.find('=', sep)) fileWrite(String("set(ENV{") + word.substr(0, sep) + "} \"" + word.substr(sep + 1) + "\")\n"); else { cCompiler = word; break; } } if(!cCompiler.isEmpty()) { if(!::File::isPathAbsolute(cCompiler) && ::File::exists(cCompiler)) fileWrite(String("set(CMAKE_C_COMPILER \"${CMAKE_CURRENT_SOURCE_DIR}/../../") + cCompiler + "\")\n"); else fileWrite(String("set(CMAKE_C_COMPILER \"") + cCompiler + "\")\n"); } } /* if(!target.cppFlags.isEmpty()) fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY COMPILE_FLAGS \"" + join(target.cppFlags) + "\")\n"); */ if(!target.cppFlags.isEmpty()) fileWrite(String("set(CMAKE_CXX_FLAGS \"") + join(target.cppFlags) + "\")\n"); if(!target.cFlags.isEmpty()) fileWrite(String("set(CMAKE_C_FLAGS \"") + join(target.cFlags) + "\")\n"); if(!target.output.isEmpty()) { String outputDirectory = ::File::getDirname(target.output.getFirst()->data); // Hi cmake devs! I do not know whats considered to be an ARCHIVE, LIBRARY or RUNTIME. So I will set all properties to be sure. fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY ARCHIVE_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n"); fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY LIBRARY_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n"); fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY RUNTIME_OUTPUT_DIRECTORY \"" + translatePath(outputDirectory) + "\")\n"); String outputName = ::File::getWithoutExtension(::File::getBasename(target.output.getFirst()->data)); outputName.patsubst("lib%", "%"); fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY OUTPUT_NAME \"" + outputName + "\")\n"); } if(!target.linkFlags.isEmpty()) { if(config.type == ProjectConfiguration::staticLibraryType) fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY STATIC_LIBRARY_FLAGS " + join(target.linkFlags) + ")\n"); else fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY LINK_FLAGS \"" + join(target.linkFlags) + "\")\n"); } if(!target.defines.isEmpty()) fileWrite(String("set_property(TARGET ") + targetName + " PROPERTY COMPILE_DEFINITIONS " + join(target.defines) + ")\n"); if(!target.dependencies.isEmpty()) fileWrite(String("add_dependencies(") + targetName + " " + join(target.dependencies) + ")\n"); } fileWrite("endif()\n"); fileClose(); return true; }