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
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
octobus
Poulpe
Commits
8665188fd939
Commit
8665188fd939
authored
2 years ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
resulte-compare: make the key comparison more flexible
We want to be able to configure it.
parent
e2a31b27845c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python-libs/poulpe/bin/result-compare
+52
-21
52 additions, 21 deletions
python-libs/poulpe/bin/result-compare
with
52 additions
and
21 deletions
python-libs/poulpe/bin/result-compare
+
52
−
21
View file @
8665188f
...
...
@@ -9,6 +9,7 @@
(
'
data-env-vars
'
,
'
name
'
),
(
'
benchmark
'
,
'
name
'
),
(
'
bin-env-vars
'
,
'
hg
'
,
'
flavor
'
),
(
'
bin-env-vars
'
,
'
hg
'
,
'
changeset
'
,
'
node
'
),
]
...
...
@@ -12,14 +13,15 @@
]
def
key_result
(
result
):
headers
=
[]
for
key
in
HEADERS_KEYS
:
treck
=
list
(
key
[::
-
1
])
current
=
result
while
treck
and
current
is
not
None
:
k
=
treck
.
pop
()
current
=
current
.
get
(
k
)
if
current
is
not
None
:
headers
.
append
((
"
.
"
.
join
(
key
),
current
))
def
get_value
(
key
,
result
):
treck
=
list
(
key
[::
-
1
])
current
=
result
while
treck
and
current
is
not
None
:
k
=
treck
.
pop
()
current
=
current
.
get
(
k
)
return
current
def
make_key_result
(
compare_key
):
headers_keys
=
[
k
for
k
in
HEADERS_KEYS
if
k
!=
compare_key
]
...
...
@@ -25,11 +27,24 @@
variants
=
result
[
'
benchmark
'
].
get
(
'
variants
'
,
{})
for
key
,
value
in
sorted
(
variants
.
items
()):
headers
.
append
((
f
"
benchmark.variants.
{
key
}
"
,
value
))
return
tuple
(
headers
)
def
key_result
(
result
):
headers
=
[]
for
key
in
headers_keys
:
value
=
get_value
(
key
,
result
)
if
value
is
not
None
:
headers
.
append
((
"
.
"
.
join
(
key
),
value
))
variant_cmp_key
=
"
.
"
.
join
(
compare_key
)
variants
=
result
[
'
benchmark
'
].
get
(
'
variants
'
,
{})
for
key
,
value
in
sorted
(
variants
.
items
()):
key
=
f
"
benchmark.variants.
{
key
}
"
if
key
==
variant_cmp_key
:
continue
headers
.
append
((
key
,
value
))
return
tuple
(
headers
)
return
key_result
def
_rank
(
result
):
return
result
[
'
bin-env-vars
'
][
'
hg
'
][
'
changeset
'
][
'
rank
'
]
...
...
@@ -30,9 +45,10 @@
def
_rank
(
result
):
return
result
[
'
bin-env-vars
'
][
'
hg
'
][
'
changeset
'
][
'
rank
'
]
def
dispatch_results
(
results
):
def
dispatch_results
(
results
,
compare_key
):
key_func
=
make_key_result
(
compare_key
)
dispatched
=
collections
.
defaultdict
(
list
)
for
r
in
results
:
...
...
@@ -37,6 +53,6 @@
dispatched
=
collections
.
defaultdict
(
list
)
for
r
in
results
:
headers
=
key_
result
(
r
)
headers
=
key_
func
(
r
)
dispatched
[
headers
].
append
(
r
)
for
some_results
in
dispatched
.
values
():
...
...
@@ -40,8 +56,17 @@
dispatched
[
headers
].
append
(
r
)
for
some_results
in
dispatched
.
values
():
some_results
.
sort
(
key
=
_rank
)
key
=
SORT_KEYS
.
get
(
compare_key
)
if
key
is
None
:
def
key
(
res
):
val
=
get_value
(
compare_key
,
res
)
if
val
is
None
:
val
=
''
return
val
some_results
.
sort
(
key
=
key
)
return
dispatched
...
...
@@ -44,8 +69,8 @@
return
dispatched
def
display_results
(
results
):
def
display_results
(
results
,
compare_key
):
for
headers
,
some_results
in
sorted
(
results
.
items
()):
key_size
=
max
(
len
(
k
)
for
k
,
v
in
headers
)
prefix
=
"
###
"
...
...
@@ -57,7 +82,9 @@
base
=
None
# display the result now
for
r
in
some_results
:
key
=
r
[
'
bin-env-vars
'
][
'
hg
'
][
'
changeset
'
][
'
node
'
][:
12
]
key
=
get_value
(
compare_key
,
r
)
if
compare_key
[
-
1
]
==
'
node
'
:
key
=
key
[:
12
]
median
=
r
[
'
result
'
][
'
time
'
][
'
median
'
]
if
base
is
None
:
base
=
median
...
...
@@ -75,6 +102,9 @@
click
.
echo
(
f
"
{
key
}
:
{
median
:
6.6
f
}
{
display
}
"
)
SORT_KEYS
=
{(
'
bin-env-vars
'
,
'
hg
'
,
'
changeset
'
,
'
node
'
):
_rank
}
@click.command
()
@click.argument
(
"
file
"
,
type
=
click
.
File
(),
default
=
"
-
"
)
def
result_compare
(
file
):
...
...
@@ -82,8 +112,9 @@
`poulpe result-search --content-as-json | poulpe result-compare`
"""
all_results
=
json
.
load
(
file
)
results
=
dispatch_results
(
all_results
)
display_results
(
results
)
compare_key
=
(
'
bin-env-vars
'
,
'
hg
'
,
'
changeset
'
,
'
node
'
)
results
=
dispatch_results
(
all_results
,
compare_key
)
display_results
(
results
,
compare_key
)
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