| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // =====================================================================================
- //
- // 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 <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- using namespace std;
- 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 = 120;
- string line, tmp;
- int size, old_size = 0;
- double time, old_time = 0;
- char exact = 'h';
- while (getline(infile, line)) {
- istringstream is(line);
- is >> tmp >> size >> time;
- if (time > cutoff) {
- size = old_size;
- time = old_time;
- }
- else {
- old_size = size;
- old_time = time;
- }
- }
- std::cout << seed << '\t' << size << '\t' << time << '\t' << exact << std::endl;
- return 0;
- }
|