Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
b128d8e7
Commit
b128d8e7
authored
Apr 04, 2018
by
Matt Traudt
Browse files
Log mean bandwidth per v3bw line
parent
67f098a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
sbws/commands/generate.py
View file @
b128d8e7
...
...
@@ -85,6 +85,12 @@ def gen_parser(sub):
'out, and we do so proportionally'
)
def
log_stats
(
data_lines
):
total_bw
=
sum
([
l
.
bw
for
l
in
data_lines
])
bw_per_line
=
total_bw
/
len
(
data_lines
)
/
1024
log
.
info
(
'Mean bandwidth per line: {:.2f} "KiB"'
.
format
(
bw_per_line
))
def
main
(
args
,
conf
,
log_
):
global
log
log
=
log_
...
...
@@ -104,6 +110,7 @@ def main(args, conf, log_):
data_lines
=
[
result_data_to_v3bw_line
(
data
,
fp
)
for
fp
in
data
]
data_lines
=
sorted
(
data_lines
,
key
=
lambda
d
:
d
.
bw
,
reverse
=
True
)
data_lines
=
scale_lines
(
args
,
data_lines
)
log_stats
(
data_lines
)
with
open
(
args
.
output
,
'wt'
)
as
fd
:
fd
.
write
(
'{}
\n
'
.
format
(
int
(
time
.
time
())))
for
line
in
data_lines
:
...
...
Write
Preview
Supports
Markdown
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