⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scope_timer.hpp

📁 Octane v1.01.20 The Open Compression Toolkit for C++ . The Open Compression Toolkit is a set of mo
💻 HPP
字号:
//
// Simple timer, measuring time from construction to destruction.
//
// Copyright (c) 2003 by Octane Project Group
// All Rights Reserved
//
// http://octane.sourceforge.net/
//

/// @file   scope_timer.hpp
/// @brief  Simple timer, measuring time from construction to destruction.
/// @author Jibz
/// @date   2003.07.30

#ifndef OCTANE_SCOPE_TIMER_HPP_INCLUDED
#define OCTANE_SCOPE_TIMER_HPP_INCLUDED

#include <iostream>
#include <string>

#include "timer.hpp"

/// Simple timer, measuring time from construction to destruction.
///
/// @ingroup Utility
///
class OctaneScopeTimer {

public:
    /// Constructor.
    /// @param _pre  - string to display before time.
    /// @param _post - string to display after time.
    /// @param _to   - stream for output.
    OctaneScopeTimer(const std::string _pre="<scope_timer> ",
                 const std::string _post=" seconds\n",
                 std::ostream &_to=std::cout)
       : pre(_pre), post(_post), to(_to)
    { ; }

    /// Get the elapsed time since construction.
    /// @return elapsed time.
    float get_elapsed() { return t.stop(); }

    /// Destructor. Outputs the elapsed time along with the pre-
    /// and post messages.
    ~OctaneScopeTimer() { to << pre << t.stop() << post; }

private:
    const std::string pre, post;
    std::ostream &to;
    OctaneTimer t;
};

#endif // OCTANE_SCOPE_TIMER_HPP_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -