Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Ratas
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Ratas
Commits
bc27c0f2
Commit
bc27c0f2
authored
Jul 23, 2016
by
Juho Snellman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the benchmark parameters configurable at runtime
parent
c483fe4f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
src/test/test_benchmark.cc
src/test/test_benchmark.cc
+34
-3
No files found.
src/test/test_benchmark.cc
View file @
bc27c0f2
// -*- mode: c++; c-basic-offset: 4 indent-tabs-mode: nil -*-
*/
// -*- mode: c++; c-basic-offset: 4 indent-tabs-mode: nil -*-
//
//
// Copyright 2016 Juho Snellman, released under a MIT license (see
// Copyright 2016 Juho Snellman, released under a MIT license (see
// LICENSE).
// LICENSE).
...
@@ -12,7 +12,8 @@ static bool allow_schedule_in_range = true;
...
@@ -12,7 +12,8 @@ static bool allow_schedule_in_range = true;
// Set to true to print a trace, to confirm that different timer
// Set to true to print a trace, to confirm that different timer
// implementations give the same results. (Or close enough results,
// implementations give the same results. (Or close enough results,
// if using non-deterministic features like schedule_in_range).
// if using non-deterministic features like schedule_in_range).
static
bool
print_trace
=
false
;
static
bool
print_trace
=
true
;
static
int
create_interval
=
5
;
class
Unit
{
class
Unit
{
public:
public:
...
@@ -140,7 +141,7 @@ bool bench() {
...
@@ -140,7 +141,7 @@ bool bench() {
while
(
rand
()
%
2
==
0
)
{
while
(
rand
()
%
2
==
0
)
{
make_unit_pair
(
&
timers
,
1000
*
50
+
rand
()
%
100
);
make_unit_pair
(
&
timers
,
1000
*
50
+
rand
()
%
100
);
}
}
timers
.
advance
(
10
);
timers
.
advance
(
create_interval
);
}
}
while
(
timers
.
now
()
<
300
*
1000
*
50
)
{
while
(
timers
.
now
()
<
300
*
1000
*
50
)
{
...
@@ -152,6 +153,36 @@ bool bench() {
...
@@ -152,6 +153,36 @@ bool bench() {
}
}
int
main
(
void
)
{
int
main
(
void
)
{
if
(
char
*
s
=
getenv
(
"BENCH_ALLOW_SCHEDULE_IN_RANGE"
))
{
std
::
string
value
=
s
;
if
(
value
==
"yes"
)
{
allow_schedule_in_range
=
true
;
}
else
if
(
value
==
"no"
)
{
allow_schedule_in_range
=
false
;
}
else
{
fprintf
(
stderr
,
"BENCH_ALLOW_SCHEDULE_IN_RANGE should be yes, no or not set"
);
return
1
;
}
}
if
(
char
*
s
=
getenv
(
"BENCH_PRINT_TRACE"
))
{
std
::
string
value
=
s
;
if
(
value
==
"yes"
)
{
print_trace
=
true
;
}
else
if
(
value
==
"no"
)
{
print_trace
=
false
;
}
else
{
fprintf
(
stderr
,
"BENCH_PRINT_TRACE should be yes, no or not set"
);
return
1
;
}
}
if
(
char
*
s
=
getenv
(
"BENCH_CREATE_INTERVAL"
))
{
char
dummy
;
if
(
sscanf
(
s
,
"%d%c"
,
&
create_interval
,
&
dummy
)
!=
1
)
{
fprintf
(
stderr
,
"BENCH_CREATE_INTERVAL should an integer"
);
return
1
;
}
}
bench
();
bench
();
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment