Skip to content
Snippets Groups Projects
CPUTime.h 804 B
Newer Older
  • Learn to ignore specific revisions
  • Lars Bilke's avatar
    Lars Bilke committed
    /**
    
    Lars Bilke's avatar
    Lars Bilke committed
     * \file
     * \author Thomas Fischer
    
     * \author Wenqing Wang
     * \date   2012-05-10, 2014.10.10
    
    Lars Bilke's avatar
    Lars Bilke committed
     * \brief  Definition of the CPUTime class.
     *
     * \copyright
    
     * Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
    
    Lars Bilke's avatar
    Lars Bilke committed
     *            Distributed under a Modified BSD License.
     *              See accompanying file LICENSE.txt or
    
    Lars Bilke's avatar
    Lars Bilke committed
     *              http://www.opengeosys.org/project/license
    
    namespace BaseLib
    {
    
    /// Count CPU time
    
    Dmitri Naumov's avatar
    Dmitri Naumov committed
    public:
        /// Start the timer.
        void start() { start_time_ = clock(); }
    
        /// Get the elapsed time after started.
        double elapsed() const
        {
            return (clock() - start_time_) / static_cast<double>(CLOCKS_PER_SEC);
        }
    
    Dmitri Naumov's avatar
    Dmitri Naumov committed
    private:
        double start_time_ = 0.;
    
    Dmitri Naumov's avatar
    Dmitri Naumov committed
    }  // end namespace BaseLib