Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
13cc6b65
Commit
13cc6b65
authored
15 years ago
by
g0dil
Browse files
Options
Downloads
Patches
Plain Diff
Scheduler: Add scheduler timer latency test
parent
4565a260
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Scheduler/FIFORunner.cc
+2
-0
2 additions, 0 deletions
Scheduler/FIFORunner.cc
Scheduler/TimerEvent.hh
+1
-0
1 addition, 0 deletions
Scheduler/TimerEvent.hh
Scheduler/TimerEvent.test.cc
+63
-0
63 additions, 0 deletions
Scheduler/TimerEvent.test.cc
with
66 additions
and
0 deletions
Scheduler/FIFORunner.cc
+
2
−
0
View file @
13cc6b65
...
@@ -89,6 +89,8 @@ prefix_ void senf::scheduler::detail::FIFORunner::startWatchdog()
...
@@ -89,6 +89,8 @@ prefix_ void senf::scheduler::detail::FIFORunner::startWatchdog()
watchdogRunning_
=
true
;
watchdogRunning_
=
true
;
}
}
else
stopWatchdog
();
}
}
prefix_
void
senf
::
scheduler
::
detail
::
FIFORunner
::
stopWatchdog
()
prefix_
void
senf
::
scheduler
::
detail
::
FIFORunner
::
stopWatchdog
()
...
...
This diff is collapsed.
Click to expand it.
Scheduler/TimerEvent.hh
+
1
−
0
View file @
13cc6b65
...
@@ -116,6 +116,7 @@ namespace scheduler {
...
@@ -116,6 +116,7 @@ namespace scheduler {
\param[in] initiallyEnabled if set \c false, do not
\param[in] initiallyEnabled if set \c false, do not
enable callback automatically. */
enable callback automatically. */
ClockService
::
clock_type
timeout
()
const
;
ClockService
::
clock_type
timeout
()
const
;
///< Get current/last timeout value
private:
private:
virtual
void
v_run
();
virtual
void
v_run
();
...
...
This diff is collapsed.
Click to expand it.
Scheduler/TimerEvent.test.cc
+
63
−
0
View file @
13cc6b65
...
@@ -29,9 +29,11 @@
...
@@ -29,9 +29,11 @@
// Custom includes
// Custom includes
#include
"TimerEvent.hh"
#include
"TimerEvent.hh"
#include
"Scheduler.hh"
#include
"Scheduler.hh"
#include
<boost/bind.hpp>
#include
"../Utils//auto_unit_test.hh"
#include
"../Utils//auto_unit_test.hh"
#include
<boost/test/test_tools.hpp>
#include
<boost/test/test_tools.hpp>
#include
<boost/random.hpp>
#define prefix_
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
///////////////////////////////cc.p////////////////////////////////////////
...
@@ -83,6 +85,67 @@ BOOST_AUTO_UNIT_TEST(timerDispatcher)
...
@@ -83,6 +85,67 @@ BOOST_AUTO_UNIT_TEST(timerDispatcher)
}
}
}
}
namespace
{
senf
::
ClockService
::
clock_type
randomDelay
()
{
static
boost
::
uniform_smallint
<>
random
(
100
,
300
);
static
boost
::
mt19937
generator
;
return
senf
::
scheduler
::
now
()
+
senf
::
ClockService
::
milliseconds
(
random
(
generator
));
}
unsigned
count
(
0
);
senf
::
ClockService
::
clock_type
delay
(
0
);
void
jitterCb
(
senf
::
scheduler
::
TimerEvent
&
tm
)
{
std
::
cerr
<<
senf
::
scheduler
::
now
()
<<
' '
<<
tm
.
timeout
()
<<
'\n'
;
count
++
;
delay
+=
senf
::
scheduler
::
now
()
-
tm
.
timeout
();
tm
.
timeout
(
randomDelay
());
}
void
logSchedulerTime
()
{
std
::
cerr
<<
senf
::
scheduler
::
now
()
<<
'\n'
;
}
void
jitterTest
()
{
count
=
0
;
delay
=
0
;
senf
::
scheduler
::
TimerEvent
tm1
(
"jitterTest::tm1"
,
boost
::
bind
(
&
jitterCb
,
boost
::
ref
(
tm1
)),
randomDelay
());
senf
::
scheduler
::
TimerEvent
tm2
(
"jitterTest::tm2"
,
boost
::
bind
(
&
jitterCb
,
boost
::
ref
(
tm2
)),
randomDelay
());
senf
::
scheduler
::
TimerEvent
tm3
(
"jitterTest::tm3"
,
boost
::
bind
(
&
jitterCb
,
boost
::
ref
(
tm3
)),
randomDelay
());
senf
::
scheduler
::
TimerEvent
timeout
(
"jitterTest::timeout"
,
&
senf
::
scheduler
::
terminate
,
senf
::
scheduler
::
now
()
+
senf
::
ClockService
::
seconds
(
5
));
senf
::
scheduler
::
EventHook
timerCalled
(
"jitterTest::logSchedulerTime"
,
&
logSchedulerTime
,
senf
::
scheduler
::
EventHook
::
PRE
);
senf
::
scheduler
::
process
();
std
::
cerr
<<
"Average scheduling delay: "
<<
delay
/
count
<<
"
\n
"
;
}
}
BOOST_AUTO_UNIT_TEST
(
timerJitter
)
{
senf
::
scheduler
::
watchdogTimeout
(
0
);
std
::
cerr
<<
"Epoll timers
\n
"
;
senf
::
scheduler
::
loresTimers
();
jitterTest
();
std
::
cerr
<<
"Hires timers
\n
"
;
senf
::
scheduler
::
hiresTimers
();
jitterTest
();
senf
::
scheduler
::
watchdogTimeout
(
1000
);
}
///////////////////////////////cc.e////////////////////////////////////////
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
#undef prefix_
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment