|
|
|||
File indexing completed on 2026-09-15 09:16:47
0001 // Created on: 2002-04-03 0002 // Created by: Michael SAZONOV 0003 // Copyright (c) 2002-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef OSD_PerfMeter_HeaderFile 0017 #define OSD_PerfMeter_HeaderFile 0018 0019 #include <Standard_Macro.hxx> 0020 #include <TCollection_AsciiString.hxx> 0021 0022 //! This class enables measuring the CPU time between two points of code execution, regardless of 0023 //! the scope of these points of code. A meter is identified by its name (string). So multiple 0024 //! objects in various places of user code may point to the same meter. The results will be printed 0025 //! on stdout upon finish of the program. For details see OSD_PerfMeter.h 0026 class OSD_PerfMeter 0027 { 0028 public: 0029 //! Constructs a void meter (to further call Init and Start). 0030 Standard_EXPORT OSD_PerfMeter() = default; 0031 0032 //! Constructs and starts (if autoStart is true) the named meter. 0033 //! @param theMeterName Name of the meter. If the meter with such name was already created, 0034 //! and hasn't been killed, it will be used. 0035 //! @param theToAutoStart If true, the meter will be started immediately after creation. 0036 //! Otherwise, the user should call Start() method to start the meter. 0037 //! Note that if meter already exists, theToAutoStart == true will reset it. 0038 Standard_EXPORT OSD_PerfMeter(const TCollection_AsciiString& theMeterName, 0039 const bool theToAutoStart = true); 0040 0041 //! Destructs this meter handler. Note that the meter itself is not destructed 0042 //! and will be printed on stdout upon finish of the program. The meter with the name 0043 //! Specified in the constructor can still be used in other places of the code. 0044 Standard_EXPORT ~OSD_PerfMeter(); 0045 0046 //! Prepares the named meter. If the meter with such name was already created, 0047 //! it will be used. Otherwise, a new meter will be created. 0048 Standard_EXPORT void Init(const TCollection_AsciiString& theMeterName); 0049 0050 //! Starts the meter. If the meter was already started, it will be reset. 0051 //! Note that the meter with the name specified in the constructor can still be used 0052 //! in other places of the code. 0053 Standard_EXPORT void Start() const; 0054 0055 //! Stops the meter. 0056 Standard_EXPORT void Stop() const; 0057 0058 //! Returns the elapsed time in seconds since the meter was started. 0059 Standard_EXPORT double Elapsed() const; 0060 0061 //! Outputs the meter data and resets it to initial state. 0062 Standard_EXPORT void Kill() const; 0063 0064 //! Prints the data of this meter. 0065 Standard_EXPORT TCollection_AsciiString Print() const; 0066 0067 //! Prints the data of all meters with non-zero elapsed time. 0068 Standard_EXPORT static TCollection_AsciiString PrintALL(); 0069 0070 //! Resets all meters. 0071 Standard_EXPORT static void ResetALL(); 0072 0073 private: 0074 TCollection_AsciiString myMeterName; 0075 }; 0076 0077 #endif // OSD_PerfMeter_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|