Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
emper
Commits
a4cc5a07
Commit
a4cc5a07
authored
6 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
Add time_to_spawn evaluation
parent
fbfa8889
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
eval/CMakeLists.txt
+2
-0
2 additions, 0 deletions
eval/CMakeLists.txt
eval/TimeToSpawn.cpp
+64
-0
64 additions, 0 deletions
eval/TimeToSpawn.cpp
with
68 additions
and
0 deletions
CMakeLists.txt
+
2
−
0
View file @
a4cc5a07
...
...
@@ -109,6 +109,8 @@ add_subdirectory("apps")
add_subdirectory
(
"tests"
)
add_subdirectory
(
"eval"
)
file
(
GLOB ALL_SOURCE_FILES *.cpp
)
file
(
GLOB ALL_HEADER_FILES *.hpp
)
...
...
This diff is collapsed.
Click to expand it.
eval/CMakeLists.txt
0 → 100644
+
2
−
0
View file @
a4cc5a07
add_executable
(
time_to_spawn TimeToSpawn.cpp
)
target_link_libraries
(
time_to_spawn Threads::Threads emper
)
This diff is collapsed.
Click to expand it.
eval/TimeToSpawn.cpp
0 → 100644
+
64
−
0
View file @
a4cc5a07
#include
"Runtime.hpp"
#include
"BinaryPrivateSemaphore.hpp"
#include
<chrono>
#include
<thread>
#include
<mutex>
static
std
::
chrono
::
nanoseconds
threadTimeToSpawn
()
{
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>
end
;
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
std
::
thread
t
([
&
end
]
{
end
=
std
::
chrono
::
high_resolution_clock
::
now
();
});
t
.
join
();
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
end
-
start
);
}
static
std
::
chrono
::
nanoseconds
fiberTimeToSpawn
()
{
std
::
chrono
::
nanoseconds
res
;
Runtime
runtime
;
std
::
mutex
testFinished
;
testFinished
.
lock
();
Fiber
*
fiber
=
Fiber
::
from
([
&
runtime
,
&
res
,
&
testFinished
]
{
BPS
bps
;
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>
end
;
Fiber
*
fiber
=
Fiber
::
from
([
&
end
,
&
bps
]
{
end
=
std
::
chrono
::
high_resolution_clock
::
now
();
bps
.
signal
();
});
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
runtime
.
schedule
(
*
fiber
);
bps
.
wait
();
res
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
end
-
start
);
testFinished
.
unlock
();
});
runtime
.
schedule
(
*
fiber
);
testFinished
.
lock
();
// The destructor of Runtime causes all runtime threads to terminate.
return
res
;
}
int
main
(
UNUSED_ARG
int
argc
,
UNUSED_ARG
char
*
argv
[])
{
{
auto
ttts
=
threadTimeToSpawn
();
std
::
cout
<<
"Thread time to spawn: "
<<
ttts
.
count
()
<<
"us"
<<
std
::
endl
;
}
{
auto
ftts
=
fiberTimeToSpawn
();
std
::
cout
<<
"Fiber time to spawn: "
<<
ftts
.
count
()
<<
"us"
<<
std
::
endl
;
}
}
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