mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0025514: TKernel, OSD_Timer - do not accumulate error in timer within queries in running state
Test-case for issue #25514 Update of test-case
This commit is contained in:
parent
150e93a7f2
commit
7e7bbb3a9e
@ -58,25 +58,25 @@ is
|
|||||||
-- the chronometer.
|
-- the chronometer.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out) is virtual;
|
Show (me) is virtual;
|
||||||
---Purpose: Shows the current CPU user and system time on the
|
---Purpose: Shows the current CPU user and system time on the
|
||||||
-- standard output stream <cout>.
|
-- standard output stream <cout>.
|
||||||
-- The chronometer can be running (laps Time) or stopped.
|
-- The chronometer can be running (laps Time) or stopped.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out; os : in out OStream from Standard) is virtual;
|
Show (me; os : in out OStream from Standard) is virtual;
|
||||||
---Purpose: Shows the current CPU user and system time on the output
|
---Purpose: Shows the current CPU user and system time on the output
|
||||||
-- stream <os>.
|
-- stream <os>.
|
||||||
-- The chronometer can be running (laps Time) or stopped.
|
-- The chronometer can be running (laps Time) or stopped.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out; UserSeconds : in out Real from Standard) ;
|
Show (me; theUserSeconds : in out Real from Standard);
|
||||||
---Purpose: Returns the current CPU user time in a variable.
|
---Purpose: Returns the current CPU user time in a variable.
|
||||||
-- The chronometer can be running (laps Time) or stopped.
|
-- The chronometer can be running (laps Time) or stopped.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out; UserSeconds : in out Real from Standard;
|
Show (me; theUserSeconds : in out Real from Standard;
|
||||||
SystemSeconds : in out Real from Standard) ;
|
theSystemSeconds : in out Real from Standard);
|
||||||
---Purpose: Returns the current CPU user and system time in variables.
|
---Purpose: Returns the current CPU user and system time in variables.
|
||||||
-- The chronometer can be running (laps Time) or stopped.
|
-- The chronometer can be running (laps Time) or stopped.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
@ -231,7 +231,7 @@ void OSD_Chronometer::Start ()
|
|||||||
//function : Show
|
//function : Show
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void OSD_Chronometer::Show ()
|
void OSD_Chronometer::Show() const
|
||||||
{
|
{
|
||||||
Show (cout);
|
Show (cout);
|
||||||
}
|
}
|
||||||
@ -240,39 +240,69 @@ void OSD_Chronometer::Show ()
|
|||||||
//function : Show
|
//function : Show
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void OSD_Chronometer::Show (Standard_OStream& os)
|
void OSD_Chronometer::Show (Standard_OStream& os) const
|
||||||
{
|
{
|
||||||
Standard_Boolean StopSav = Stopped;
|
Standard_Real aCumulUserSec = Cumul_user;
|
||||||
if (!StopSav) Stop();
|
Standard_Real aCumulSysSec = Cumul_sys;
|
||||||
|
if (!Stopped)
|
||||||
|
{
|
||||||
|
Standard_Real aCurrUser, aCurrSys;
|
||||||
|
if (ThreadOnly)
|
||||||
|
GetThreadCPU (aCurrUser, aCurrSys);
|
||||||
|
else
|
||||||
|
GetProcessCPU (aCurrUser, aCurrSys);
|
||||||
|
|
||||||
|
aCumulUserSec += aCurrUser - Start_user;
|
||||||
|
aCumulSysSec += aCurrSys - Start_sys;
|
||||||
|
}
|
||||||
|
|
||||||
std::streamsize prec = os.precision (12);
|
std::streamsize prec = os.precision (12);
|
||||||
os << "CPU user time: " << Cumul_user << " seconds " << endl;
|
os << "CPU user time: " << aCumulUserSec << " seconds " << endl;
|
||||||
os << "CPU system time: " << Cumul_sys << " seconds " << endl;
|
os << "CPU system time: " << aCumulSysSec << " seconds " << endl;
|
||||||
os.precision (prec);
|
os.precision (prec);
|
||||||
if (!StopSav) Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Show
|
//function : Show
|
||||||
//purpose : Returns cpu user time
|
//purpose : Returns cpu user time
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void OSD_Chronometer::Show (Standard_Real& second)
|
void OSD_Chronometer::Show (Standard_Real& theUserSec) const
|
||||||
{
|
{
|
||||||
Standard_Boolean StopSav = Stopped;
|
theUserSec = Cumul_user;
|
||||||
if (!StopSav) Stop();
|
if (Stopped)
|
||||||
second = Cumul_user;
|
{
|
||||||
if (!StopSav) Start();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Real aCurrUser, aCurrSys;
|
||||||
|
if (ThreadOnly)
|
||||||
|
GetThreadCPU (aCurrUser, aCurrSys);
|
||||||
|
else
|
||||||
|
GetProcessCPU (aCurrUser, aCurrSys);
|
||||||
|
|
||||||
|
theUserSec += aCurrUser - Start_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Show
|
//function : Show
|
||||||
//purpose : Returns both user and system cpu times
|
//purpose : Returns both user and system cpu times
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void OSD_Chronometer::Show (Standard_Real& user,
|
void OSD_Chronometer::Show (Standard_Real& theUserSec,
|
||||||
Standard_Real& system)
|
Standard_Real& theSystemSec) const
|
||||||
{
|
{
|
||||||
Standard_Boolean StopSav = Stopped;
|
theUserSec = Cumul_user;
|
||||||
if (!StopSav) Stop();
|
theSystemSec = Cumul_sys;
|
||||||
user = Cumul_user;
|
if (Stopped)
|
||||||
system = Cumul_sys;
|
{
|
||||||
if (!StopSav) Start();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Standard_Real aCurrUser, aCurrSys;
|
||||||
|
if (ThreadOnly)
|
||||||
|
GetThreadCPU (aCurrUser, aCurrSys);
|
||||||
|
else
|
||||||
|
GetProcessCPU (aCurrUser, aCurrSys);
|
||||||
|
|
||||||
|
theUserSec += aCurrUser - Start_user;
|
||||||
|
theSystemSec += aCurrSys - Start_sys;
|
||||||
|
}
|
||||||
|
@ -41,21 +41,21 @@ is
|
|||||||
---Purpose: Stops and reinitializes the timer.
|
---Purpose: Stops and reinitializes the timer.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out) is redefined;
|
Show (me) is redefined;
|
||||||
---Purpose: Shows both the elapsed time and CPU time on the standard output
|
---Purpose: Shows both the elapsed time and CPU time on the standard output
|
||||||
-- stream <cout>.The chronometer can be running (Lap Time) or
|
-- stream <cout>.The chronometer can be running (Lap Time) or
|
||||||
-- stopped.
|
-- stopped.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out; os : in out OStream from Standard) is redefined;
|
Show (me; os : in out OStream from Standard) is redefined;
|
||||||
---Purpose: Shows both the elapsed time and CPU time on the
|
---Purpose: Shows both the elapsed time and CPU time on the
|
||||||
-- output stream <OS>.
|
-- output stream <OS>.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Show (me : in out; seconds : in out Real from Standard;
|
Show (me; theSeconds : in out Real from Standard;
|
||||||
minutes : in out Integer from Standard;
|
theMinutes : in out Integer from Standard;
|
||||||
hours : in out Integer from Standard;
|
theHours : in out Integer from Standard;
|
||||||
CPUtime : in out Real from Standard);
|
theCPUtime : in out Real from Standard);
|
||||||
|
|
||||||
---Purpose: returns both the elapsed time(seconds,minutes,hours)
|
---Purpose: returns both the elapsed time(seconds,minutes,hours)
|
||||||
-- and CPU time.
|
-- and CPU time.
|
||||||
@ -70,7 +70,7 @@ is
|
|||||||
-- the Timer.
|
-- the Timer.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
ElapsedTime (me : in out) returns Real;
|
ElapsedTime (me) returns Real;
|
||||||
---Purpose: Returns elapsed time in seconds.
|
---Purpose: Returns elapsed time in seconds.
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void OSD_Timer::Reset ()
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void OSD_Timer::Show ()
|
void OSD_Timer::Show() const
|
||||||
{
|
{
|
||||||
Show (cout);
|
Show (cout);
|
||||||
}
|
}
|
||||||
@ -125,16 +125,14 @@ void OSD_Timer::Show ()
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Real OSD_Timer::ElapsedTime()
|
Standard_Real OSD_Timer::ElapsedTime() const
|
||||||
{
|
{
|
||||||
if (!Stopped)
|
if (Stopped)
|
||||||
{
|
{
|
||||||
// update cumulative time
|
return TimeCumul;
|
||||||
Stop();
|
|
||||||
Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TimeCumul;
|
return TimeCumul + GetWallClockTime() - TimeStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -142,43 +140,39 @@ Standard_Real OSD_Timer::ElapsedTime()
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void OSD_Timer::Show (Standard_Real& seconds,
|
void OSD_Timer::Show (Standard_Real& theSeconds,
|
||||||
Standard_Integer& minutes,
|
Standard_Integer& theMinutes,
|
||||||
Standard_Integer& hours,
|
Standard_Integer& theHours,
|
||||||
Standard_Real& CPUtime)
|
Standard_Real& theCPUtime) const
|
||||||
{
|
{
|
||||||
Standard_Boolean StopSav=Stopped;
|
const Standard_Real aTimeCumul = Stopped
|
||||||
if (!StopSav) Stop();
|
? TimeCumul
|
||||||
|
: TimeCumul + GetWallClockTime() - TimeStart;
|
||||||
Compute (TimeCumul, hours, minutes, seconds);
|
Compute (aTimeCumul, theHours, theMinutes, theSeconds);
|
||||||
OSD_Chronometer::Show(CPUtime);
|
OSD_Chronometer::Show (theCPUtime);
|
||||||
|
|
||||||
if (!StopSav) Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Show
|
//function : Show
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void OSD_Timer::Show (Standard_OStream& os)
|
void OSD_Timer::Show (Standard_OStream& os) const
|
||||||
{
|
{
|
||||||
Standard_Boolean StopSav=Stopped;
|
const Standard_Real aTimeCumul = Stopped
|
||||||
if (!StopSav) Stop();
|
? TimeCumul
|
||||||
|
: TimeCumul + GetWallClockTime() - TimeStart;
|
||||||
|
|
||||||
Standard_Integer heure,minut;
|
Standard_Integer anHours, aMinutes;
|
||||||
Standard_Real second;
|
Standard_Real aSeconds;
|
||||||
Compute (TimeCumul, heure, minut, second);
|
Compute (aTimeCumul, anHours, aMinutes, aSeconds);
|
||||||
|
|
||||||
std::streamsize prec = os.precision (12);
|
std::streamsize prec = os.precision (12);
|
||||||
os << "Elapsed time: " << heure << " Hours " <<
|
os << "Elapsed time: " << anHours << " Hours " <<
|
||||||
minut << " Minutes " <<
|
aMinutes << " Minutes " <<
|
||||||
second << " Seconds " << endl;
|
aSeconds << " Seconds " << endl;
|
||||||
OSD_Chronometer::Show(os);
|
OSD_Chronometer::Show(os);
|
||||||
os.precision (prec);
|
os.precision (prec);
|
||||||
|
|
||||||
if (!StopSav) Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
48
tests/bugs/fclasses/bug25514
Normal file
48
tests/bugs/fclasses/bug25514
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC25514"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
#########################################################################################
|
||||||
|
# TKernel, OSD_Timer - do not accumulate error in timer within queries in running state
|
||||||
|
#########################################################################################
|
||||||
|
|
||||||
|
# Set number of cycle iteration
|
||||||
|
set IterationCount 10000
|
||||||
|
set iCounter 1
|
||||||
|
|
||||||
|
# Set rank of timer's value
|
||||||
|
set TimeRank 2
|
||||||
|
|
||||||
|
# Start timers
|
||||||
|
dchrono bug_info_1 reset
|
||||||
|
dchrono bug_info_2 reset
|
||||||
|
dchrono bug_info_1 start
|
||||||
|
dchrono bug_info_2 start
|
||||||
|
|
||||||
|
# Operation cycle (show only one timer state)
|
||||||
|
while {$iCounter != $IterationCount} {
|
||||||
|
dchrono bug_info_1 show
|
||||||
|
set iCounter [expr {$iCounter + 1}]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stop timers
|
||||||
|
dchrono bug_info_1 stop
|
||||||
|
dchrono bug_info_2 stop
|
||||||
|
|
||||||
|
# Get timers value
|
||||||
|
set Timer_1 [dchrono bug_info_1 show]
|
||||||
|
set Timer_2 [dchrono bug_info_2 show]
|
||||||
|
|
||||||
|
# Modify timers value for comparison
|
||||||
|
set TimerValue_1 [lindex $Timer_1 6]
|
||||||
|
set TimerValue_1 [string range $TimerValue_1 0 [expr {[string first "." $TimerValue_1] + $TimeRank}]]
|
||||||
|
set TimerValue_2 [lindex $Timer_2 6]
|
||||||
|
set TimerValue_2 [string range $TimerValue_2 0 [expr {[string first "." $TimerValue_2] + $TimeRank}]]
|
||||||
|
|
||||||
|
# Comparison of timer's values
|
||||||
|
puts "Compare: [lindex $Timer_1 6] vs [lindex $Timer_2 6]"
|
||||||
|
if {$TimerValue_1 != $TimerValue_2} {
|
||||||
|
puts "ERROR: OCC25514 is reproduced."
|
||||||
|
} else {
|
||||||
|
puts "OK"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user