Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
octobus
Poulpe
Commits
41c2aa05
Commit
41c2aa05
authored
6 years ago
by
Boris Feld
Browse files
Options
Downloads
Patches
Plain Diff
Update asv_result_time to display results as a tree
parent
d0b30ec6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/asv_result_time.py
+52
-12
52 additions, 12 deletions
script/asv_result_time.py
with
52 additions
and
12 deletions
script/asv_result_time.py
+
52
−
12
View file @
41c2aa05
...
...
@@ -4,6 +4,10 @@
import
json
import
operator
import
sys
from
collections
import
defaultdict
nested_dict
=
lambda
:
defaultdict
(
nested_dict
)
def
split_name
(
name
):
...
...
@@ -7,7 +11,9 @@
def
split_name
(
name
):
return
name
"""
Split a
"""
return
name
.
split
(
"
.
"
)
def
read_result_file
(
result_file
):
...
...
@@ -16,8 +22,10 @@
def
parse_result_file
(
result
):
times
=
{}
times
=
defaultdict
(
lambda
:
datetime
.
timedelta
())
hierarchy
=
nested_dict
()
total_time
=
datetime
.
timedelta
()
for
name
,
start
in
result
[
"
started_at
"
].
items
():
...
...
@@ -20,9 +28,13 @@
total_time
=
datetime
.
timedelta
()
for
name
,
start
in
result
[
"
started_at
"
].
items
():
times
[
name
]
=
datetime
.
timedelta
(
seconds
=
(
result
[
"
ended_at
"
][
name
]
-
start
)
/
1000.0
)
total_time
+=
times
[
name
]
top_level
=
hierarchy
seconds
=
(
result
[
"
ended_at
"
][
name
]
-
start
)
/
1000.0
delta
=
datetime
.
timedelta
(
seconds
=
seconds
)
total_time
+=
delta
splitted_name
=
split_name
(
name
)
...
...
@@ -28,4 +40,12 @@
return
times
,
total_time
for
i
,
part
in
enumerate
(
splitted_name
):
full_part_name
=
"
.
"
.
join
(
splitted_name
[:
i
+
1
])
# Store the hierarchy of results
top_level
=
top_level
[
full_part_name
]
times
[
full_part_name
]
+=
delta
return
times
,
hierarchy
,
total_time
...
...
@@ -30,6 +50,6 @@
def
format_results
(
times
,
total_time
):
def
format_results
(
times
,
hierarchy
,
total_time
):
fmt
=
"
{:<70} {:>10} {:>10}%
"
print
(
fmt
.
format
(
"
Benchmark
"
,
"
Time
"
,
""
))
print
(
fmt
.
format
(
"
Total
"
,
total_time
,
"
100
"
))
...
...
@@ -33,5 +53,17 @@
fmt
=
"
{:<70} {:>10} {:>10}%
"
print
(
fmt
.
format
(
"
Benchmark
"
,
"
Time
"
,
""
))
print
(
fmt
.
format
(
"
Total
"
,
total_time
,
"
100
"
))
for
name
,
btime
in
sorted
(
times
.
items
(),
key
=
operator
.
itemgetter
(
1
),
reverse
=
True
):
format_sub_results
(
times
,
hierarchy
,
total_time
)
def
format_sub_results
(
times
,
hierarchy
,
total_time
,
level
=
0
):
fmt
=
"
{:<70} {:>10} {:>10}%
"
for
full_name
in
sorted
(
hierarchy
.
keys
(),
key
=
lambda
bname
:
times
[
bname
],
reverse
=
True
):
name
=
full_name
.
split
(
"
.
"
)[
-
1
]
btime
=
times
[
full_name
]
percent
=
"
%.2f
"
%
(
btime
.
total_seconds
()
/
total_time
.
total_seconds
()
*
100
,)
...
...
@@ -37,7 +69,15 @@
percent
=
"
%.2f
"
%
(
btime
.
total_seconds
()
/
total_time
.
total_seconds
()
*
100
,)
print
(
fmt
.
format
(
name
,
btime
,
percent
))
fmt_level
=
"
"
*
(
level
*
2
)
print
(
fmt
.
format
(
fmt_level
+
name
,
btime
,
percent
))
sub_benchmarks
=
hierarchy
[
full_name
]
if
sub_benchmarks
:
format_sub_results
(
times
,
sub_benchmarks
,
total_time
,
level
=
level
+
1
)
# for name, btime in sorted(times.items(), key=operator.itemgetter(1), reverse=True):
def
main
(
result_file
):
result
=
read_result_file
(
result_file
)
...
...
@@ -39,7 +79,7 @@
def
main
(
result_file
):
result
=
read_result_file
(
result_file
)
times
,
total_time
=
parse_result_file
(
result
)
times
,
hierarchy
,
total_time
=
parse_result_file
(
result
)
...
...
@@ -45,5 +85,5 @@
format_results
(
times
,
total_time
)
format_results
(
times
,
hierarchy
,
total_time
)
if
__name__
==
"
__main__
"
:
...
...
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