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

📄 timer.h

📁 利用C
💻 H
字号:
// Copyright (C) 2008 Anders Logg.// Licensed under the GNU LGPL Version 2.1.//// First added:  2008-06-13// Last changed: 2008-06-13#ifndef __TIMER_H#define __TIMER_H#include <dolfin/log/LogManager.h>#include "timing.h"namespace dolfin{  /// A timer can be used for timing tasks. The basic usage is  ///  ///   Timer timer("Assembling over cells");  ///  /// The timer is started at construction and timing ends  /// when the timer is destroyed (goes out of scope). It is  /// also possible to start and stop a timer explicitly by  ///  ///   timer.start();  ///   timer.stop();  ///  /// Timings are stored globally and a summary may be printed  /// by calling  ///  ///   summary();  class Timer  {  public:    /// Create timer    Timer(std::string task) : task(task), t(time()), stopped(false) {}    /// Destructor    ~Timer() { if (!stopped) stop(); }    /// Start timer    inline void start() { t = time(); stopped = false; }        /// Stop timer    void stop() { LogManager::logger.timing(task, time() - t); stopped = true; }  private:    // Name of task    std::string task;    // Start time    real t;    // True if timer has been stopped    bool stopped;  };}#endif

⌨️ 快捷键说明

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