U1 Resource::ParseConfig(CAString& strConfig){ CoreMesh* pCoreMesh = new CoreMesh(m_strProductName); m_pObject = (UInt*)pCoreMesh; Data pData; ResourceSystem::GetSingleton()->Find(m_strProductName + m_strSkeleton,pData); if(pData.IsNull()) return false; if(!pCoreMesh->loadCoreSkeleton(pData.buff)){ SAF_D(pCoreMesh); return false; } ResourceSystem::GetSingleton()->Find(strConfig,pData); if(pData.IsNull()) return false; CSV csv; csv.Load(pData.buff,pData.size); for(U32 i=1;i<csv.GetLineCount();i++) { LoadAnimation(csv.GetItem(4,i).pStr); } return true; }
int main(){ std::ifstream file("/home/blacklizard/Desktop/MigrationLIst/bin/Debug/member.csv"); CSV * data = new CSV; data->readAllRow(file); data->writeToFile(); return 0; }
void VideoBasedTracker::dumpKeypointDebugData( std::vector<cv::KeyPoint> const &keypoints) { { std::cout << "Dumping blob detection debug data, capture frame " << m_debugFrame << std::endl; cv::imwrite("debug_rawimage" + std::to_string(m_debugFrame) + ".png", m_frame); cv::imwrite("debug_blobframe" + std::to_string(m_debugFrame) + ".png", m_imageWithBlobs); cv::imwrite("debug_thresholded" + std::to_string(m_debugFrame) + ".png", m_thresholdImage); } { auto filename = std::string{"debug_data" + std::to_string(m_debugFrame) + ".txt"}; std::ofstream datafile{filename.c_str()}; datafile << "MinThreshold: " << m_sbdParams.minThreshold << std::endl; datafile << "MaxThreshold: " << m_sbdParams.maxThreshold << std::endl; datafile << "ThresholdStep: " << m_sbdParams.thresholdStep << std::endl; datafile << "Thresholds:" << std::endl; for (double thresh = m_sbdParams.minThreshold; thresh < m_sbdParams.maxThreshold; thresh += m_sbdParams.thresholdStep) { datafile << thresh << std::endl; } } { using namespace osvr::util; CSV kpcsv; for (auto &keypoint : keypoints) { kpcsv.row() << cell("x", keypoint.pt.x) << cell("y", keypoint.pt.y) << cell("size", keypoint.size); } auto filename = std::string{"debug_blobdetect" + std::to_string(m_debugFrame) + ".csv"}; std::ofstream csvfile{filename.c_str()}; kpcsv.output(csvfile); csvfile.close(); } std::cout << "Data dump complete." << std::endl; m_debugFrame++; }
CSV ReadResultCSV() { ifstream in("result.csv"); if (!in.is_open()) { throw runtime_error("Unable to open result file!"); }; CSV lines; string fullLine; while (getline(in, fullLine)) { Tokenizer tok(fullLine, escaped_list_separator<char>('\\', ';', '\"')); vector<string> splittedLine; splittedLine.assign(tok.begin(), tok.end()); lines.push_back(splittedLine); } return lines; }
FreeMillerLibrary::FreeMillerLibrary(std::string filename, double maxResolution) { double freeProportion = FileParser::getKey("FREE_MILLER_FRACTION", 0.05); int spaceGroup = FileParser::getKey("SPACE_GROUP", 0); std::vector<double> unitCell = FileParser::getKey("UNIT_CELL", std::vector<double>()); if (spaceGroup == 0) { std::cout << "Space group is unassigned! Please assign your space group using the command SPACE_GROUP in order to generate a free Miller set during refinement." << std::endl; exit(1); } if (unitCell.size() == 0) { std::cout << "Please specify the UNIT_CELL in order to generate a free Miller set during refinement." << std::endl; exit(1); } UnitCellLatticePtr lattice = UnitCellLatticePtr(new UnitCellLattice(unitCell[0], unitCell[1], unitCell[2], unitCell[3], unitCell[4], unitCell[5], spaceGroup, maxResolution)); for (int i = 0; i < lattice->standardVectorCount(); i++) { vec3<int> oneVec = lattice->intVector(i); double randomNumber = rand() / (double)RAND_MAX; if (randomNumber < freeProportion) { freeIndices.push_back(oneVec); } } if (filename != "") { CSV csv = CSV(3, "h", "k", "l"); for (int i = 0; i < freeIndexCount(); i++) { csv.addEntry(0, (double)freeIndices[i][0], (double)freeIndices[i][1], (double)freeIndices[i][2]); } csv.writeToFile(filename); } }
std::vector<jeopardy::Question> loadQuestions(CSV& csv) { std::vector<Question> questions; for(int i = 0; i < 7; i++) { std::cout << "--- " << csv.next() << std::endl; // Skip over the column titles. } while(csv.good()) { Question q; q.showNumber = csv.next(); q.airDate = csv.next(); q.round = csv.next(); q.category = csv.next(); q.value = csv.next(); q.question = csv.next(); q.answer = csv.next(); questions.push_back(q); } return questions; }
void DoTimedTest(const std::string& name, size_t n, std::function<void(size_t count)> f) { Time start; f(n); Time stop; long duration_us = stop.DiffUSecs(start); long duration_ms = duration_us / 1000; double rate = (n) / (1.0 * duration_ms); double cost = 1000* duration_us / (1.0 * n); if ( baseline_duration == 0 ) { baseline_duration = duration_us; cout << "| "; cout << setw(50) << left << name; cout << " | "; cout << left << setw(22) << duration_ms; cout << " | "; cout << setw(14) << left << rate; cout << " | "; cout << setw(14) << left << cost; cout << " |"; } else { long durationRatio = (duration_us / baseline_duration); cout << "| "; cout << setw(50) << left << name; cout << " | "; std::stringstream buf; buf << left << duration_ms << " (x" << durationRatio<< ")"; cout << setw(22) << buf.str(); cout << " | "; cout << setw(14) << left << rate; cout << " | "; cout << setw(14) << left << cost; cout << " |"; } results.AddRow(std::string(name),duration_us+0); cout << endl; }
int main(int argc, const char *argv[]) { std::map<std::string,std::string> args; for (int i = 0; i < argc; ++i) { std::string arg(argv[i]); if (arg.length() > 1 && arg[0] == '-') { arg = arg.substr(1); size_t split_pos = arg.find("="); if (split_pos != std::string::npos) { std::string name = arg.substr(0,split_pos); std::string value = arg.substr(split_pos+1); args[name] = value; } else { args[arg] = "SET"; } } } bool threads = (args["noThreads"] != "SET"); if (args["count"] != "") { long tmpCount = atol(args["count"].c_str()); if (tmpCount > 0) { COUNT = tmpCount; } } if (args["threadTorture"] != "") { DoTimedTest("Pushing to 10 client, 3 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,3); }); return 0; } Header(COUNT); DoTimedTest("Baseline Loop",COUNT, BaselineLoop); DoTimedTest("Baseline Queue",COUNT, BaselineQueue); /** * Pushing when there are no clients... */ Footer(); DoTimedTest("Pushing with no clients",COUNT, EmptyPush); /** * Pushing to clients who are not consuming data (the queue is just getting bigger...) */ Footer(); DoTimedTest("Pushing to 1 client, no reads",COUNT, [] (size_t count) -> void { IgnoringClients(count,1);}); DoTimedTest("Pushing to 2 clients, no reads",COUNT, [] (size_t count) -> void { IgnoringClients(count,2);}); DoTimedTest("Pushing to 3 clients, no reads",COUNT, [] (size_t count) -> void { IgnoringClients(count,3);}); DoTimedTest("Pushing to 5 clients, no reads",COUNT, [] (size_t count) -> void { IgnoringClients(count,5);}); DoTimedTest("Pushing to 10 clients, no reads",COUNT, [] (size_t count) -> void { IgnoringClients(count,10);}); Footer(); DoTimedTest("Pushing to 1 client, single thread",COUNT, [] (size_t count) -> void { PassiveClients(count,1); }); DoTimedTest("Pushing to 2 client, single thread",COUNT, [] (size_t count) -> void { PassiveClients(count,2); }); DoTimedTest("Pushing to 3 client, single thread",COUNT, [] (size_t count) -> void { PassiveClients(count,3); }); DoTimedTest("Pushing to 5 client, single thread",COUNT, [] (size_t count) -> void { PassiveClients(count,5); }); DoTimedTest("Pushing to 10 client, single thread",COUNT, [] (size_t count) -> void { PassiveClients(count,10); }); Footer(); DoTimedTest("Fowarding to 1 client, single thread",COUNT, [] (size_t count) -> void { OnNewMessage(count,1); }); DoTimedTest("Fowarding to 2 client, single thread",COUNT, [] (size_t count) -> void { OnNewMessage(count,2); }); DoTimedTest("Fowarding to 3 client, single thread",COUNT, [] (size_t count) -> void { OnNewMessage(count,3); }); DoTimedTest("Fowarding to 5 client, single thread",COUNT, [] (size_t count) -> void { OnNewMessage(count,5); }); DoTimedTest("Fowarding to 10 client, single thread",COUNT, [] (size_t count) -> void { OnNewMessage(count,10); }); Footer(); DoTimedTest("Fowarding to 1 client, single thread, batched",COUNT, [] (size_t count) -> void { OnNewMessageBatched(count,1); }); DoTimedTest("Fowarding to 2 client, single thread, batched",COUNT, [] (size_t count) -> void { OnNewMessageBatched(count,2); }); DoTimedTest("Fowarding to 3 client, single thread, batched",COUNT, [] (size_t count) -> void { OnNewMessageBatched(count,3); }); DoTimedTest("Fowarding to 5 client, single thread, batched",COUNT, [] (size_t count) -> void { OnNewMessageBatched(count,5); }); DoTimedTest("Fowarding to 10 client, single thread, batched",COUNT, [] (size_t count) -> void { OnNewMessageBatched(count,10); }); Footer(); DoTimedTest("Fowarding to 1 custom client, single thread",COUNT, [] (size_t count) -> void { OnNewMessageCustom(count,1); }); DoTimedTest("Fowarding to 2 custom client, single thread",COUNT, [] (size_t count) -> void { OnNewMessageCustom(count,2); }); DoTimedTest("Fowarding to 3 custom client, single thread",COUNT, [] (size_t count) -> void { OnNewMessageCustom(count,3); }); DoTimedTest("Fowarding to 5 custom client, single thread",COUNT, [] (size_t count) -> void { OnNewMessageCustom(count,5); }); DoTimedTest("Fowarding to 10 custom client, single thread",COUNT, [] (size_t count) -> void { OnNewMessageCustom(count,10); }); if (threads) { Footer(); DoTimedTest("Pushing to 1 client, 1 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,1,1); }); DoTimedTest("Pushing to 2 client, 1 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,2,1); }); DoTimedTest("Pushing to 3 client, 1 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,3,1); }); DoTimedTest("Pushing to 5 client, 1 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,5,1); }); DoTimedTest("Pushing to 10 client, 1 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,1); }); Footer(); DoTimedTest("Pushing to 2 client, 2 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,2,2); }); DoTimedTest("Pushing to 3 client, 2 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,3,2); }); DoTimedTest("Pushing to 5 client, 2 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,5,2); }); DoTimedTest("Pushing to 10 client, 2 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,2); }); Footer(); DoTimedTest("Pushing to 3 client, 3 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,3,3); }); DoTimedTest("Pushing to 5 client, 3 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,5,3); }); DoTimedTest("Pushing to 10 client, 3 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,3); }); Footer(); DoTimedTest("Pushing to 5 client, 5 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,5,5); }); DoTimedTest("Pushing to 10 client,5 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,5); }); Footer(); DoTimedTest("Pushing to 10 client,10 client thread",COUNT, [] (size_t count) -> void { ThreadConsumers(count,10,10); }); Footer(); DoTimedTest("Pushing to 1 client, 1 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,1,1); }); DoTimedTest("Pushing to 2 client, 1 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,2,1); }); DoTimedTest("Pushing to 3 client, 1 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,3,1); }); DoTimedTest("Pushing to 5 client, 1 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,5,1); }); DoTimedTest("Pushing to 10 client, 1 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,10,1); }); Footer(); DoTimedTest("Pushing to 2 client, 2 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,2,2); }); DoTimedTest("Pushing to 3 client, 2 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,3,2); }); DoTimedTest("Pushing to 5 client, 2 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,5,2); }); DoTimedTest("Pushing to 10 client, 2 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,10,2); }); Footer(); DoTimedTest("Pushing to 3 client, 3 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,3,3); }); DoTimedTest("Pushing to 5 client, 3 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,5,3); }); DoTimedTest("Pushing to 10 client, 3 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,10,3); }); Footer(); DoTimedTest("Pushing to 5 client, 5 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,5,5); }); DoTimedTest("Pushing to 10 client,5 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,10,5); }); Footer(); DoTimedTest("Pushing to 10 client,10 client thread, batched",COUNT, [] (size_t count) -> void { ThreadConsumersBatched(count,10,10); }); } Footer(); const char* fname = "results.csv"; if ( args["file"] != "") { fname = args["file"].c_str(); } OFStreamWriter resultsFile(fname); results.WriteCSV(resultsFile); return 0; }
int main() { CSV *testcv = new CSV("EEG_Samples.csv"); testcv->fn_readFile(); delete testcv; return 0; }
int main(int argc, char** argv){ try{ if(argc != 3){ throw TitorError( INCORRECT_ARG_NUMBER, QString()+ +"usage: " +argv[0] +" <pipeline file> <output>\n" +"A line of the pipeline is in this format:\n" +"<signal name> <signal width> <start> <end>\n" +"start and end are inclusive and indicate the pipeline" +" phases at which the signal starts and ends respectively." ); } CSV source; StreamManager st; source.read(argv[1]); QUtfStream& out = st.spawnU(argv[2], WRITE); QVector<pipeline> holder; for(int i=0; i<source.sqheight(); ++i){ if(source.rowwidth(i) != 4){ throw TitorError( BAD_TYPED_SPREADSHEET, QString()+"Row:"+QString::number(i) +" is of incorrect length "+QString::number(source.rowwidth(i)) ); } if(!source.is_int(i,2)){ throw TitorError( BAD_TYPED_SPREADSHEET, QString()+"Row:"+QString::number(i) +" Column: 2 unable to convert \""+source.gString(i,2)+"\" to an integer" ); } if(!source.is_int(i,3)){ throw TitorError( BAD_TYPED_SPREADSHEET, QString()+"Row:"+QString::number(i) +" Column:2 unable to convert \""+source.gString(i,3)+"\" to an integer" ); } const QString name = source.gString(i,0); const QString width = source.gString(i,1); const int start = source.gInt(i,2); const int end = source.gInt(i,3); holder.push_back(pipeline(name, width, start, end)); } // wiring for(int i=0; i<holder.size(); ++i){ holder[i].wiring(out); } out << "\n"; // aliasing out << "always @(*) begin\n"; for(int i=0; i<holder.size(); ++i){ holder[i].aliasing(out); } out << "end\n"; out << "\n"; // clocking out << "always @(posedge clk) begin\n"; for(int i=0; i<holder.size(); ++i){ holder[i].clocking(out); } out << "end\n"; return 0; } catch(TitorError e){ qerr << msg << e.m_error << endl; return e.m_code; } }