Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
8a6ad59d
Unverified
Commit
8a6ad59d
authored
8 years ago
by
René Fritze
Browse files
Options
Downloads
Patches
Plain Diff
[testing] make distribution and its result stable
parent
4336da68
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/scripts/distribute_testing.py
+20
-10
20 additions, 10 deletions
python/scripts/distribute_testing.py
with
20 additions
and
10 deletions
python/scripts/distribute_testing.py
+
20
−
10
View file @
8a6ad59d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
os
import
os
import
pickle
import
pickle
import
json
import
sys
import
sys
from
pprint
import
pprint
from
pprint
import
pprint
import
subprocess
import
subprocess
...
@@ -9,11 +10,11 @@ import time
...
@@ -9,11 +10,11 @@ import time
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
import
binpacking
import
binpacking
from
multiprocessing
import
Pool
,
cpu_count
from
multiprocessing
import
Pool
,
cpu_count
from
collections
import
OrderedDict
MAXTIME
=
23
*
60
MAXTIME
=
23
*
60
pickle_file
=
'
totals.pickle
'
pickle_file
=
'
totals.pickle
'
PROTOCOL
=
0
@contextmanager
@contextmanager
def
elapsed_timer
():
def
elapsed_timer
():
...
@@ -24,6 +25,15 @@ def elapsed_timer():
...
@@ -24,6 +25,15 @@ def elapsed_timer():
end
=
clock
()
end
=
clock
()
elapser
=
lambda
:
end
-
start
elapser
=
lambda
:
end
-
start
def
_dump
(
obj
,
fn
):
json
.
dump
(
obj
,
open
(
fn
,
'
wt
'
),
sort_keys
=
True
)
def
_load
(
fn
):
try
:
return
json
.
load
(
open
(
fn
,
'
rt
'
))
except
:
return
pickle
.
load
(
open
(
fn
,
'
rb
'
))
def
_compile
(
binary
):
def
_compile
(
binary
):
with
elapsed_timer
()
as
timer
:
with
elapsed_timer
()
as
timer
:
...
@@ -75,31 +85,31 @@ def do_timings(builddir, pickledir, binaries, testnames, processes, headerlibs):
...
@@ -75,31 +85,31 @@ def do_timings(builddir, pickledir, binaries, testnames, processes, headerlibs):
targets
=
binaries
+
headerlibs
targets
=
binaries
+
headerlibs
compiles_fn
=
os
.
path
.
join
(
pickledir
,
'
compiles_
'
+
pickle_file
)
compiles_fn
=
os
.
path
.
join
(
pickledir
,
'
compiles_
'
+
pickle_file
)
try
:
try
:
compiles
=
pickle
.
load
(
open
(
compiles_fn
,
'
rb
'
)
)
compiles
=
_load
(
compiles_fn
)
if
set
(
compiles
.
keys
())
!=
set
(
targets
):
if
set
(
compiles
.
keys
())
!=
set
(
targets
):
print
(
'
redoing compiles due to mismatched binaries
'
)
print
(
'
redoing compiles due to mismatched binaries
'
)
compiles
=
_redo
(
processes
,
targets
,
_compile
,
targets
)
compiles
=
_redo
(
processes
,
targets
,
_compile
,
targets
)
except
FileNotFoundError
:
except
FileNotFoundError
:
print
(
'
redoing compiles due to missing pickle
'
)
print
(
'
redoing compiles due to missing pickle
'
)
compiles
=
_redo
(
processes
,
targets
,
_compile
,
targets
)
compiles
=
_redo
(
processes
,
targets
,
_compile
,
targets
)
pickle
.
dump
(
compiles
,
open
(
compiles_fn
,
'
wb
'
)
)
_
dump
(
compiles
,
compiles_fn
)
testnames
=
testnames
[:
testlimit
]
testnames
=
testnames
[:
testlimit
]
testruns_fn
=
os
.
path
.
join
(
pickledir
,
'
testruns_
'
+
pickle_file
)
testruns_fn
=
os
.
path
.
join
(
pickledir
,
'
testruns_
'
+
pickle_file
)
try
:
try
:
loaded_testnames
,
testruns
=
pickle
.
load
(
open
(
testruns_fn
,
'
rb
'
)
)
loaded_testnames
,
testruns
=
_load
(
testruns_fn
)
if
set
(
compiles
.
keys
())
!=
set
(
targets
)
or
loaded_testnames
!=
testnames
:
if
set
(
compiles
.
keys
())
!=
set
(
targets
)
or
loaded_testnames
!=
testnames
:
print
(
'
redoing tests due to mismatched binaries/testnames
'
)
print
(
'
redoing tests due to mismatched binaries/testnames
'
)
testruns
=
_redo
(
processes
,
binaries
,
_run_tests
,
zip
(
binaries
,
testnames
))
testruns
=
_redo
(
processes
,
binaries
,
_run_tests
,
zip
(
binaries
,
testnames
))
except
FileNotFoundError
:
except
FileNotFoundError
:
print
(
'
redoing tests due to missing pickle
'
)
print
(
'
redoing tests due to missing pickle
'
)
testruns
=
_redo
(
processes
,
binaries
,
_run_tests
,
zip
(
binaries
,
testnames
))
testruns
=
_redo
(
processes
,
binaries
,
_run_tests
,
zip
(
binaries
,
testnames
))
pickle
.
dump
((
testnames
,
testruns
),
open
(
testruns_fn
,
'
wb
'
)
)
_
dump
((
testnames
,
testruns
),
testruns_fn
)
totals
=
{
n
:
compiles
[
n
]
+
testruns
[
n
]
for
n
in
binaries
}
totals
=
{
n
:
compiles
[
n
]
+
testruns
[
n
]
for
n
in
binaries
}
# add totals for headerlib compiles that do not have associated testruns
# add totals for headerlib compiles that do not have associated testruns
totals
.
update
({
n
:
compiles
[
n
]
for
n
in
headerlibs
})
totals
.
update
({
n
:
compiles
[
n
]
for
n
in
headerlibs
})
pickle
.
dump
(
totals
,
open
(
os
.
path
.
join
(
pickledir
,
pickle_file
)
,
'
wb
'
)
)
_
dump
(
totals
,
os
.
path
.
join
(
pickledir
,
pickle_file
))
# print('totals')
# print('totals')
# pprint(totals)
# pprint(totals)
return
totals
return
totals
...
@@ -121,7 +131,7 @@ processes = cpu_count()
...
@@ -121,7 +131,7 @@ processes = cpu_count()
totals
=
do_timings
(
builddir
,
testdir
,
binaries
,
all_testnames
,
processes
,
headerlibs
)
totals
=
do_timings
(
builddir
,
testdir
,
binaries
,
all_testnames
,
processes
,
headerlibs
)
bins
=
binpacking
.
to_constant_volume
(
totals
,
MAXTIME
)
#
bins = binpacking.to_constant_volume(totals, MAXTIME)
bins
=
binpacking
.
to_constant_bin_number
(
totals
,
bincount
)
bins
=
binpacking
.
to_constant_bin_number
(
totals
,
bincount
)
#for idx, bin in enumerate(bins):
#for idx, bin in enumerate(bins):
#pprint('Bin {} vol: {}'.format(idx, sum(bin.values())))
#pprint('Bin {} vol: {}'.format(idx, sum(bin.values())))
...
@@ -135,8 +145,8 @@ print('Generated {} bins.\nRelative volumes:\n\t\tMin {:.2f}%\n\t\tMax {:.2f}%\n
...
@@ -135,8 +145,8 @@ print('Generated {} bins.\nRelative volumes:\n\t\tMin {:.2f}%\n\t\tMax {:.2f}%\n
with
open
(
cmake_outfile
,
'
wt
'
)
as
out
:
with
open
(
cmake_outfile
,
'
wt
'
)
as
out
:
out
.
write
(
'
set(DXT_BIN_COUNT
"
{}
"
CACHE STRING
"
number of bins for test targets
"
)
\n
'
.
format
(
len
(
bins
)))
out
.
write
(
'
set(DXT_BIN_COUNT
"
{}
"
CACHE STRING
"
number of bins for test targets
"
)
\n
'
.
format
(
len
(
bins
)))
for
idx
,
bin
in
enumerate
(
bins
):
for
idx
,
bin
in
enumerate
(
bins
):
out
.
write
(
'
add_custom_target(test_binaries_builder_{} DEPENDS {})
\n
'
.
format
(
idx
,
'
'
.
join
(
bin
.
keys
())))
out
.
write
(
'
add_custom_target(test_binaries_builder_{} DEPENDS {})
\n
'
.
format
(
idx
,
'
'
.
join
(
sorted
(
bin
.
keys
())))
)
for
binary
in
bin
.
keys
():
for
binary
in
sorted
(
bin
.
keys
()
)
:
if
binary
not
in
headerlibs
:
if
binary
not
in
headerlibs
:
for
testname
in
testname_map
[
binary
]:
for
testname
in
testname_map
[
binary
]:
out
.
write
(
'
set_tests_properties({} PROPERTIES LABELS
"
builder_{}
"
)
\n
'
.
format
(
testname
,
idx
))
out
.
write
(
'
set_tests_properties({} PROPERTIES LABELS
"
builder_{}
"
)
\n
'
.
format
(
testname
,
idx
))
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