Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Sortix
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
412
Issues
412
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
sortix
Sortix
Commits
63cde070
Commit
63cde070
authored
Dec 02, 2011
by
Jonas Termansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a benchmark for counting context-switches per second.
parent
b0859c6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
bench/Makefile
bench/Makefile
+1
-0
bench/benchctxswitch.cpp
bench/benchctxswitch.cpp
+23
-0
No files found.
bench/Makefile
View file @
63cde070
...
...
@@ -5,6 +5,7 @@ include ../crosscompilemakefile.mak
INITRDDIR
:=
../initrd
LOCALBINARIES
:=
\
benchsyscall
\
benchctxswitch
\
BINARIES
:=
$(
addprefix
$(INITRDDIR)
/,
$(LOCALBINARIES)
)
...
...
bench/benchctxswitch.cpp
0 → 100644
View file @
63cde070
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
int
main
(
int
argc
,
char
*
argv
[])
{
pid_t
slavepid
=
fork
();
if
(
slavepid
<
0
)
{
perror
(
"fork"
);
return
1
;
}
if
(
slavepid
==
0
)
{
while
(
true
)
{
usleep
(
0
);
}
exit
(
0
);
}
uintmax_t
start
;
if
(
uptime
(
&
start
)
)
{
perror
(
"uptime"
);
return
1
;
}
uintmax_t
end
=
start
+
1ULL
*
1000ULL
;
// 1 second
size_t
count
=
0
;
uintmax_t
now
;
while
(
!
uptime
(
&
now
)
&&
now
<
end
)
{
usleep
(
0
);
count
+=
2
;
/* back and forth */
}
printf
(
"Made %zu context switches in 1 second
\n
"
,
count
);
kill
(
slavepid
,
SIGKILL
);
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