Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphaël Gomès
repo-bencher
Commits
feb8ecb6e959
Commit
f16bf7e0
authored
Jun 22, 2020
by
Raphaël Gomès
Browse files
Add support for multiple machines
parent
a9cbd73a18e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
.hgignore
View file @
feb8ecb6
...
...
@@ -6,3 +6,4 @@ repos/
logs/
results/
config.json
machine.json
README.md
View file @
feb8ecb6
...
...
@@ -32,6 +32,17 @@ You also need the ``config.json`` file at the root of this repository. Here is a
}
```
Finally, you need a
``machine.json``
file at the root of this repository, as follows:
```
json
{
"version"
:
0
,
"name"
:
"my-machine-name"
}
```
Note that the machine name should be a valid path component.
## Usage
Run the benchmarks:
...
...
bench.py
View file @
feb8ecb6
...
...
@@ -56,6 +56,7 @@ def post_process_results(
exec_config
,
cmd
:
str
,
result_path
:
Path
,
machine_info
:
dict
,
):
tmp_path
=
Path
(
f
"
{
result_path
}
.tmp"
)
with
tmp_path
.
open
(
mode
=
"r"
)
as
f
:
...
...
@@ -69,6 +70,7 @@ def post_process_results(
data
=
{
"version"
:
0
,
"machine_info"
:
machine_info
,
"run_uid"
:
run_uid
.
hex
,
"repository"
:
str
(
repo_path
.
absolute
()),
"config"
:
exec_config
,
...
...
@@ -85,7 +87,9 @@ def post_process_results(
tmp_path
.
unlink
(
missing_ok
=
True
)
def
run_repo_command
(
repo_path
:
Path
,
exec_kind
:
str
,
exec_config
,
cmd
:
str
):
def
run_repo_command
(
repo_path
:
Path
,
exec_kind
:
str
,
exec_config
,
cmd
:
str
,
machine_info
:
dict
):
executable
=
exec_config
[
"path"
]
subprocess_args
=
exec_config
.
get
(
"args"
,
""
)
exec_name
=
executable
.
rsplit
(
os
.
sep
)[
-
1
]
...
...
@@ -98,6 +102,7 @@ def run_repo_command(repo_path: Path, exec_kind: str, exec_config, cmd: str):
out_path
=
(
RESULTS_DIR
/
machine_info
[
"name"
]
/
repo_path
.
name
/
exec_config
.
get
(
"executable_version"
,
""
)
/
f
"
{
filename
}
.json"
...
...
@@ -120,10 +125,12 @@ def run_repo_command(repo_path: Path, exec_kind: str, exec_config, cmd: str):
subprocess
.
run
(
full_cmd
,
check
=
True
,
shell
=
True
,
cwd
=
str
(
repo_path
))
post_process_results
(
repo_path
,
uid
,
exec_kind
,
exec_config
,
cmd
,
out_path
)
post_process_results
(
repo_path
,
uid
,
exec_kind
,
exec_config
,
cmd
,
out_path
,
machine_info
)
def
bench
(
exec_kind
:
str
,
exec_config
:
dict
):
def
bench
(
exec_kind
:
str
,
exec_config
:
dict
,
machine_info
:
dict
):
repos_tested
=
0
if
exec_kind
==
"upstream"
:
...
...
@@ -151,7 +158,9 @@ def bench(exec_kind: str, exec_config: dict):
repos_tested
+=
1
for
command
in
REPO_COMMANDS
:
run_repo_command
(
repo_path
,
exec_kind
,
exec_config
,
command
)
run_repo_command
(
repo_path
,
exec_kind
,
exec_config
,
command
,
machine_info
)
print
(
f
"[MAIN] Tested
{
repos_tested
}
repositories"
)
...
...
@@ -191,7 +200,7 @@ def print_result(res):
def
summary
():
results
=
defaultdict
(
lambda
:
defaultdict
(
list
))
results
=
defaultdict
(
lambda
:
defaultdict
(
lambda
:
defaultdict
(
list
))
)
for
root
,
dirs
,
files
in
os
.
walk
(
RESULTS_DIR
):
for
file
in
files
:
...
...
@@ -205,22 +214,25 @@ def summary():
except
json
.
JSONDecodeError
:
print
(
f
"Ignoring invalid json file
{
path
}
"
,
file
=
sys
.
stderr
)
else
:
results
[
data
[
"repository"
]][
data
[
"command"
]].
append
(
data
)
repo
=
data
[
"repository"
]
machine_name
=
data
[
"machine_info"
][
"name"
]
command
=
data
[
"command"
]
results
[
repo
][
command
][
machine_name
].
append
(
data
)
for
name
,
commands
in
sorted
(
results
.
items
()):
print
(
f
"=== Repository '
{
name
.
rsplit
(
os
.
sep
)[
-
1
]
}
' ==="
)
for
command
,
data
in
sorted
(
commands
.
items
()):
for
command
,
machines
in
sorted
(
commands
.
items
()):
print
(
f
"
\n
== Command: '
{
command
}
' =="
)
for
machine_name
,
data
in
sorted
(
machines
.
items
()):
for
res
in
sorted
(
data
,
key
=
lambda
d
:
d
[
"config"
][
"path"
]):
executable_name
=
res
[
"config"
][
"path"
].
rsplit
(
os
.
sep
)[
-
1
]
print
(
f
"
\n
--- [
{
machine_name
}
]
{
executable_name
}
"
f
"(
{
res
.
get
(
'executable_version'
)
}
) ---"
)
print_result
(
res
)
for
res
in
sorted
(
data
,
key
=
lambda
d
:
d
[
"config"
][
"path"
]):
executable_name
=
res
[
"config"
][
"path"
].
rsplit
(
os
.
sep
)[
-
1
]
print
(
f
"
\n
---
{
executable_name
}
(
{
res
.
get
(
'executable_version'
)
}
) ---"
)
print_result
(
res
)
print
(
""
)
print
(
""
)
def
main
(
args
:
argparse
.
Namespace
):
...
...
@@ -242,10 +254,27 @@ def main(args: argparse.Namespace):
with
config_file
.
open
(
mode
=
"r"
)
as
f
:
config
=
json
.
load
(
f
)
machine_file
=
BASE_DIR
/
"machine.json"
if
not
machine_file
.
exists
():
print
(
"abort: no 'machine.json' found, see README for info"
,
file
=
sys
.
stderr
,
)
exit
(
1
)
with
machine_file
.
open
(
mode
=
"r"
)
as
f
:
machine_info
=
json
.
load
(
f
)
if
not
machine_info
.
get
(
"name"
):
print
(
"abort: key 'name' is empty in 'machine.json'"
,
file
=
sys
.
stderr
,
)
exit
(
1
)
for
exec_kind
in
args
.
executables
:
print
(
f
"[MAIN] Using
{
exec_kind
}
executable"
)
try
:
bench
(
exec_kind
,
config
[
"executables"
][
exec_kind
])
bench
(
exec_kind
,
config
[
"executables"
][
exec_kind
]
,
machine_info
)
except
subprocess
.
CalledProcessError
:
# errors are logged, keep benching
pass
...
...
machine.json
0 → 100644
View file @
feb8ecb6
{
"version"
:
0
,
"name"
:
"alphare-carbon"
}
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