Skip to content

Commit f428575

Browse files
alxbilgerfredroy
authored andcommitted
[Helper] Minor improvements in AdvancedTimer
1 parent 33c64f2 commit f428575

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

Sofa/framework/Helper/src/sofa/helper/AdvancedTimer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void AdvancedTimer::end(IdTimer id, std::ostream& result)
242242
}
243243
if (id != curTimer.top())
244244
{
245-
msg_error("AdvancedTimer::end") << "timer[" << id << "] does not correspond to last call to begin(" << curTimer.top() << ")" ;
245+
msg_error("AdvancedTimer") << "Trying to end the timer \"" << id << "\" but the last call to 'begin' was for timer \"" << curTimer.top() << "\"";
246246
return;
247247
}
248248
type::vector<Record>* curRecords = getCurRecords();
@@ -286,7 +286,7 @@ void AdvancedTimer::end(IdTimer id)
286286
}
287287
if (id != curTimer.top())
288288
{
289-
msg_error("AdvancedTimer::end") << "timer[" << id << "] does not correspond to last call to begin(" << curTimer.top() << ")" ;
289+
msg_error("AdvancedTimer") << "Trying to end the timer \"" << id << "\" but the last call to 'begin' was for timer \"" << curTimer.top() << "\"";
290290
return;
291291
}
292292

Sofa/framework/Helper/src/sofa/helper/AdvancedTimer.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,40 @@ namespace sofa::helper
127127
class Record
128128
{
129129
public:
130+
/**
131+
* @brief High-resolution timestamp of the timer event in clock ticks
132+
*
133+
* This timestamp records the number of clock ticks since some reference point (not absolute time).
134+
*
135+
* **Important usage note**: When converting to seconds, you should only use time differences (e.g., `time2 - time1`).
136+
* Absolute values of this type cannot be directly converted to seconds without knowing the reference point.
137+
*/
130138
sofa::helper::system::thread::ctime_t time;
131-
enum Type { RNONE, RBEGIN, REND, RSTEP_BEGIN, RSTEP_END, RSTEP, RVAL_SET, RVAL_ADD } type;
139+
140+
/**
141+
* @enum Record::Type
142+
* @brief Type of record in the timer data.
143+
*
144+
* This enum defines the different types of records that can be stored in the timer data stream.
145+
* Each record type represents a specific timing operation or value tracking operation.
146+
*
147+
* @note The values are used to distinguish between different types of timer operations and value tracking operations.
148+
*
149+
* @{
150+
*/
151+
enum Type {
152+
RNONE, ///< No record (used for initialization)
153+
RBEGIN, ///< Begin timer operation (e.g., when a timer starts)
154+
REND, ///< End timer operation (e.g., when a timer stops)
155+
RSTEP_BEGIN, ///< Begin of a step operation (e.g., when a step starts)
156+
RSTEP_END, ///< End of a step operation (e.g., when a step ends)
157+
RSTEP, ///< Step operation (e.g., when a step is executed)
158+
RVAL_SET, ///< Set a value operation (e.g., when a value is set)
159+
RVAL_ADD ///< Add to a value operation (e.g., when a value is added)
160+
};
161+
/// @}
162+
163+
Type type;
132164
std::string label;
133165
unsigned int id;
134166
unsigned int obj;

0 commit comments

Comments
 (0)