forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove some unused functions - more range-based for loops - refactor progress() functions.
- Loading branch information
Showing
9 changed files
with
245 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// ========================================================================== | ||
// Dedmonwakeen's Raid DPS/TPS Simulator. | ||
// Send questions to [email protected] | ||
// ========================================================================== | ||
|
||
#include "simulationcraft.hpp" | ||
|
||
progress_bar_t::progress_bar_t( sim_t& s ) : | ||
sim( s ), steps( 20 ), updates( 100 ), interval( 0 ), start_time( 0 ) | ||
{ | ||
} | ||
|
||
void progress_bar_t::init() | ||
{ | ||
start_time = util::wall_time(); | ||
if ( sim.target_error > 0 ) | ||
{ | ||
interval = sim.analyze_error_interval; | ||
} | ||
else | ||
{ | ||
interval = sim.work_queue -> size() / updates; | ||
} | ||
if ( interval == 0 ) | ||
{ | ||
interval = 1; | ||
} | ||
} | ||
|
||
bool progress_bar_t::update( bool finished ) | ||
{ | ||
if ( sim.thread_index != 0 ) | ||
return false; | ||
if ( !sim.report_progress ) | ||
return false; | ||
if ( !sim.current_iteration ) | ||
return false; | ||
|
||
if ( !finished ) | ||
{ | ||
if ( sim.current_iteration % interval ) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
auto progress = sim.progress(); | ||
auto pct = progress.pct(); | ||
if ( pct <= 0 ) | ||
return false; | ||
if ( finished ) | ||
pct = 1.0; | ||
|
||
size_t prev_size = status.size(); | ||
|
||
status = "["; | ||
status.insert( 1, steps, '.' ); | ||
status += "]"; | ||
|
||
int length = static_cast<int>(steps * pct + 0.5); | ||
for ( int i = 1; i < length + 1; ++i ) | ||
status[i] = '='; | ||
if ( length > 0 ) | ||
status[length] = '>'; | ||
|
||
double current_time = util::wall_time() - start_time; | ||
double total_time = current_time / pct; | ||
|
||
int remaining_sec = int( total_time - current_time ); | ||
int remaining_min = remaining_sec / 60; | ||
remaining_sec -= remaining_min * 60; | ||
|
||
str::format( status, " %d/%d", finished ? progress.total_iterations : progress.current_iterations, progress.total_iterations ); | ||
|
||
if ( sim.target_error > 0 ) | ||
{ | ||
str::format( status, " Mean=%.0f Error=%.3f%%", sim.current_mean, sim.current_error ); | ||
} | ||
|
||
if ( remaining_min > 0 ) | ||
{ | ||
str::format( status, " %dmin", remaining_min ); | ||
} | ||
|
||
if ( remaining_sec > 0 ) | ||
{ | ||
str::format( status, " %dsec", remaining_sec ); | ||
} | ||
|
||
if ( prev_size > status.size() ) | ||
status.insert( status.end(), ( prev_size - status.size() ), ' ' ); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.