Esempio n. 1
0
StrVec read_list (const char* fname)
{
    StrVec rv;
    LineReader rd (fname);
    char *l, *lc;
    while ((l = rd.nextLine ()))
    {
        // find first token and add to rv
        while (*l && isspace (*l)) l ++;
        if (!*l) continue;
        lc = l + 1;
        while (*lc && !isspace (*lc)) lc ++;
        *lc = 0;
        rv.push_back (l);
    }
    rd.close ();
    return rv;
}
Esempio n. 2
0
bool TestFileUtils :: process ()
{
    std::string fname = fixture_.dirname ();
    fname += path_separator ();
    fname += "*.txt";
    StrVec sv;
    expand_wildcards (fname.c_str (), sv);
    StrVec::iterator itr = sv.begin ();
    for (; itr != sv.end (); itr ++)
    {
        o_ << (*itr).c_str () << std::endl;
    }
    if (!sv.size ())
    {
        o_ << "No files to test reader" << std::endl;
        return false;
    }

    LineReader lr (sv.front ().c_str ());
    char* ln;
    int no = 0;
    int slen = 0;
    time_t st = time (NULL);
    while ((ln = lr.nextLine ()))
    {
        ++ no;
        slen += strlen (ln);
        //if (strlen (ln) > 100) o_ << ln;
        if (no % 100000 == 0)
        {
            int td = time (NULL) - st;
            double rd = double (slen) / (1024*1024);
            o_ << "\rline " << no << ", " << rd << " Mb, average speed " << rd / (td?td:1) << " Mb/s    " << std::flush;
        }
    }
    time_t et = time (NULL);
    lr.close ();
    return true;
}