-
Notifications
You must be signed in to change notification settings - Fork 761
Expand file tree
/
Copy pathproc.cpp
More file actions
82 lines (67 loc) · 1.79 KB
/
proc.cpp
File metadata and controls
82 lines (67 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to natehieter@gmail.com
// ==========================================================================
#include "proc.hpp"
#include "sim/sim.hpp"
proc_t::proc_t( sim_t& s, util::string_view n, unsigned flags )
: sim( s ),
iteration_count(),
last_proc( timespan_t::min() ),
name_str( n ),
proc_report_flags( flags ),
interval_sum( "Interval", true ),
count( "Count", true )
{
}
void proc_t::occur()
{
iteration_count++;
if ( last_proc >= timespan_t::zero() && last_proc < sim.current_time() )
{
interval_sum.add( ( sim.current_time() - last_proc ).total_seconds() );
reset();
}
if ( sim.debug )
sim.out_debug.printf( "[PROC] %s: iteration_count=%u count.sum=%u last_proc=%f", name(),
static_cast<unsigned>( iteration_count ), static_cast<unsigned>( count.sum() ),
last_proc.total_seconds() );
last_proc = sim.current_time();
}
void proc_t::reset()
{
last_proc = timespan_t::min();
}
void proc_t::merge( const proc_t& other )
{
count.merge( other.count );
interval_sum.merge( other.interval_sum );
}
void proc_t::analyze()
{
count.analyze( sim );
interval_sum.analyze( sim );
}
void proc_t::datacollection_begin()
{
iteration_count = 0;
}
void proc_t::datacollection_end()
{
count.add( static_cast<double>( iteration_count ) );
}
const std::string& proc_t::name() const
{
return name_str;
}
proc_t* proc_t::collect_count( bool collect )
{
count.change_mode( !collect );
count.reserve( std::min( as<unsigned>( sim.iterations ), 2048U ) );
return this;
}
proc_t* proc_t::collect_interval( bool collect )
{
interval_sum.change_mode( !collect );
interval_sum.reserve( std::min( as<unsigned>( sim.iterations ), 2048U ) );
return this;
}