当前位置: 首页>>代码示例>>C++>>正文


C++ Duration::get_lap方法代码示例

本文整理汇总了C++中Duration::get_lap方法的典型用法代码示例。如果您正苦于以下问题:C++ Duration::get_lap方法的具体用法?C++ Duration::get_lap怎么用?C++ Duration::get_lap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Duration的用法示例。


在下文中一共展示了Duration::get_lap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: import

void CDDBSQLUpdater::import(const std::string& importfile, bool initial_import)
{
    m_rep.clear();
    
    Duration duration;

    // construct an untar object and tell it to use bz2 when the file has the
    // .bz2 suffix (it should always have..)
    UnTar tar(importfile, (importfile.rfind(".bz2") == importfile.length() - 4));

    m_sql.exec("PRAGMA synchronous=OFF");
    m_sql.exec("PRAGMA count_changes=OFF");
    m_sql.exec("PRAGMA journal_mode=MEMORY");
    m_sql.exec("PRAGMA temp_store=MEMORY");

    m_sql.exec("BEGIN TRANSACTION");

    if (initial_import) {
        m_sql.exec("DROP INDEX fuzzyid_id_idx");
    }

    UnTar::buf_t data;

    // get file after file
    while (tar.entry(data, TarHeader::File, true) != TarHeader::Unknown) {

        if (m_rep.rct && m_rep.rct % 100000 == 0) {
            duration.lap();
            std::cout << fmt::format("{0} - records read: {1}, rps: {2}",
                                     duration.to_string(Duration::Precision::Seconds),
                                     m_rep.rct,
                                     (100000*1000) / (duration.get_lap(Duration::Precision::Milliseconds)))
            << std::endl;
        }

        ++m_rep.rct;
        m_rep.bct += data.size();

        // following here is handling of normal files

        // construct DiskRecord from the data
        DiskRecord rec(data);

        // check if the record contains plausible data
        if (!rec.valid()) {

            if (m_debug) {
                std::string exterr = rec.artist() + " / " + rec.title();
                error("INVALID", exterr, data);
            }

            ++m_rep.frct;
            continue;
        }

        bool record_written = false;

        uint32_t cdid = check_title_hash(rec.normalized_hash());

        if (!cdid) {

            // this is a new record, write it
            cdid = write_record(rec, false);
            record_written = true;

        } else {

            ++m_rep.dcrcct;

            if (m_debug) {
                // this CD CRC is already known. For debug purposes, let's store them
                // to find out if they are legitimately so, or CRC collisions
                // (investigations showed they are legitimate dupes, but with differing discids due to
                // slightly different track offsets..)
                std::string exterr = fmt::format("hash duplicate: {0}", rec.normalized_hash());
                error("HASHDUP", exterr, data);
            }

            // on purpose, fall through to writing the discid links -
            // all needed data is valid: the cdid, and the rec.discid() is actually a new
            // valid discid for that already known cdid
            
        }
        
        // now write the discid link(s)
        {

            bool discid_valid = true;

            uint32_t ecd = check_discid(rec.discid());

            if (ecd) {

                // trouble - the discid is already known
                //
                // check if it is some sort of a collision
                //  a. hash collision, where different frame lengths yield the same hash value
                //  b. "real world" collision, where different CDs yield the same frame lengths
                //      (in this case we can not do a lot to resolve it automatically)
                //  c. actually same discid pointing to the same CD, which simply means that we
//.........这里部分代码省略.........
开发者ID:JoachimSchurig,项目名称:CppCDDB,代码行数:101,代码来源:cddbupdater.cpp


注:本文中的Duration::get_lap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。