Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
alex037yang
OpenXG-RAN
Commits
c3705cfc
Commit
c3705cfc
authored
Dec 05, 2016
by
Cedric Roux
Committed by
Raymond Knopp
Jan 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
T: new function 'bps'
This function is used to print rates (say '1kb/s' or '16Mb/s').
parent
5b39be88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
common/utils/T/tracer/utils.c
common/utils/T/tracer/utils.c
+11
-0
common/utils/T/tracer/utils.h
common/utils/T/tracer/utils.h
+1
-0
No files found.
common/utils/T/tracer/utils.c
View file @
c3705cfc
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <ctype.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <math.h>
void
new_thread
(
void
*
(
*
f
)(
void
*
),
void
*
data
)
void
new_thread
(
void
*
(
*
f
)(
void
*
),
void
*
data
)
{
{
...
@@ -36,6 +37,16 @@ void sleepms(int ms)
...
@@ -36,6 +37,16 @@ void sleepms(int ms)
if
(
nanosleep
(
&
t
,
NULL
))
abort
();
if
(
nanosleep
(
&
t
,
NULL
))
abort
();
}
}
void
bps
(
char
*
out
,
float
v
,
char
*
suffix
)
{
static
char
*
bps_unit
[
4
]
=
{
""
,
"k"
,
"M"
,
"G"
};
int
flog
;
if
(
v
<
1000
)
flog
=
0
;
else
flog
=
floor
(
floor
(
log10
(
v
))
/
3
);
if
(
flog
>
3
)
flog
=
3
;
v
/=
pow
(
10
,
flog
*
3
);
sprintf
(
out
,
"%g%s%s"
,
round
(
v
*
100
)
/
100
,
bps_unit
[
flog
],
suffix
);
}
/****************************************************************************/
/****************************************************************************/
/* list */
/* list */
/****************************************************************************/
/****************************************************************************/
...
...
common/utils/T/tracer/utils.h
View file @
c3705cfc
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
void
new_thread
(
void
*
(
*
f
)(
void
*
),
void
*
data
);
void
new_thread
(
void
*
(
*
f
)(
void
*
),
void
*
data
);
void
sleepms
(
int
ms
);
void
sleepms
(
int
ms
);
void
bps
(
char
*
out
,
float
v
,
char
*
suffix
);
/****************************************************************************/
/****************************************************************************/
/* list */
/* list */
...
...
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