| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // =====================================================================================
- //
- // 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 <cstdio>
- #include <fstream>
- #include <iostream>
- #include <sstream>
- #include <string>
- 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;
- }
|