// ===================================================================================== // // Filename: stat.cc // // Description: read one result // // Version: 1.0 // Created: 2018年 03月 16日 星期五 22:02:12 CST // Revision: none // Compiler: g++ // // Author: Jinkun Lin, jkunlin@gmail.com // Organization: School of EECS, Peking University // // ===================================================================================== #include #include #include #include #include using namespace std; string basename(string name) { size_t begin = name.find_last_of('/'); return name.substr(begin + 1, name.size() - begin); } int main(int argc, char const *argv[]) { if (argc != 2) { return 1; } string filename = argv[1]; ifstream infile(filename); if (!infile) { std::cout << "file" << std::endl; return 1; } size_t b = filename.find_last_of('_') + 5; size_t e = filename.find_last_of('.'); string seed = filename.substr(b, e - b); double cutoff = 100; string line, tmp; int size = 0, old_size = 0; double time = 0, old_time = 0; char exact = 'h', old_exact = 'h'; /* // fastwclq while (getline(infile, line)) { istringstream is(line); for (int i = 0; i < 2; ++i) { is >> tmp; } is >> size >> time >> tmp >> exact; if (!is) { size = old_size; time = old_time; exact = old_exact; break; } if (time > cutoff) { size = old_size; time = old_time; exact = old_exact; break; } else { old_size = size; old_time = time; old_exact = exact; } } */ // lscc while (getline(infile, line)) { istringstream is(line); for (int i = 0; i < 4; ++i) { is >> tmp; } char ch; is >> time >> ch >> size; if (!is) { size = old_size; time = old_time; exact = old_exact; break; } if (time > cutoff) { size = old_size; time = old_time; exact = old_exact; break; } else { old_size = size; old_time = time; old_exact = exact; } } // fanyi // getline(infile, line); // read time // while (getline(infile, line)) { // istringstream is(line); // for (int i = 0; i < 1; ++i) { // is >> tmp; // } // is >> size >> time; // // if (!is) { // size = old_size; // time = old_time; // exact = old_exact; // break; // } // // if (time > cutoff) { // size = old_size; // time = old_time; // exact = old_exact; // break; // } else { // old_size = size; // old_time = time; // old_exact = exact; // } // } std::cout << seed << '\t' << size << '\t' << time << '\t' << exact << std::endl; if (size == 0) { cerr << "size = 0\t" << basename(filename) << endl; } return 0; }