Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
bfaa0724
Commit
bfaa0724
authored
Aug 01, 2016
by
Quentin Khan
Browse files
PerfTest descriptor: extract the progress bar from the loader
parent
991f5abd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Tests/noDist/PerfTest/Descriptors.hpp
View file @
bfaa0724
...
...
@@ -304,43 +304,54 @@ struct uniform_tree_descriptor {
// Basic loader descriptor ///////////////////////
#include
"Files/FFmaGenericLoader.hpp"
#include
<thread>
struct
progress_bar
{
std
::
stringstream
sstr
;
std
::
thread
t
;
progress_bar
()
{
this
->
sstr
.
precision
(
3
);
}
template
<
typename
Loader
>
void
follow
(
FSize
&
idx
,
Loader
&
l
)
{
this
->
t
=
std
::
thread
(
[
this
,
&
idx
,
&
l
]()
{
bool
run
=
true
;
while
(
run
)
{
sstr
.
str
(
""
);
sstr
.
clear
();
sstr
.
precision
(
4
);
double
p
=
static_cast
<
double
>
(
idx
)
*
100.
/
static_cast
<
double
>
(
l
.
getNumberOfParticles
());
sstr
<<
"Loading particles: ["
;
for
(
double
i
=
0
;
i
<
100
;
i
+=
7.5
)
{
sstr
<<
(
i
<
p
?
'|'
:
' '
);
}
sstr
<<
"] "
<<
p
<<
"% "
;
std
::
cout
<<
'\r'
<<
sstr
.
str
()
<<
std
::
flush
;
run
=
idx
<
l
.
getNumberOfParticles
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
200
));
}
});
}
void
finish
()
{
this
->
t
.
join
();
}
};
#include
"Files/FFmaGenericLoader.hpp"
template
<
typename
FReal
>
struct
default_loader_descriptor
{
struct
loader_t
:
public
FFmaGenericLoader
<
FReal
>
{
std
::
stringstream
sstr
;
std
::
thread
t
;
void
setup_progress
(
FSize
&
idx
)
{
this
->
t
=
std
::
thread
(
[
this
,
&
idx
]()
{
bool
run
=
true
;
while
(
run
)
{
sstr
.
str
(
""
);
sstr
.
clear
();
sstr
.
precision
(
4
);
double
p
=
static_cast
<
double
>
(
idx
)
*
100.
/
static_cast
<
double
>
(
this
->
getNumberOfParticles
());
sstr
<<
"Loading particles: ["
;
for
(
double
i
=
0
;
i
<
100
;
i
+=
7.5
)
{
sstr
<<
(
i
<
p
?
'|'
:
' '
);
}
sstr
<<
"] "
<<
p
<<
"% "
;
std
::
cout
<<
'\r'
<<
sstr
.
str
()
<<
std
::
flush
;
run
=
idx
<
this
->
getNumberOfParticles
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
200
));
}
});
}
progress_bar
progress
;
loader_t
(
const
FPerfTestParams
&
params
)
:
FFmaGenericLoader
<
FReal
>
(
params
.
filename
){
this
->
sstr
.
precision
(
3
);
}
template
<
typename
tree_t
>
...
...
@@ -351,7 +362,7 @@ struct default_loader_descriptor {
FPoint
<
FReal
>
position
;
FReal
physicalValue
=
0.0
;
this
->
setup_
progress
(
idxPart
);
progress
.
follow
(
idxPart
,
*
this
);
for
(
idxPart
=
0
;
idxPart
<
this
->
getNumberOfParticles
()
;
++
idxPart
){
// Read particle per particle from file
...
...
@@ -359,7 +370,7 @@ struct default_loader_descriptor {
// put particle in octree
tree
.
insert
(
position
,
idxPart
,
physicalValue
);
}
this
->
t
.
join
();
progress
.
finish
();
std
::
cout
<<
"done."
<<
std
::
endl
;
}
};
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment