📄 scope_timer.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 + -