mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 21:30:14 -05:00
Keeps stats about usage time of disk and cpu.
This commit is contained in:
parent
fb4f257593
commit
5dfc67ec18
11 changed files with 230 additions and 8 deletions
|
|
@ -117,6 +117,21 @@ struct snapraid_state {
|
|||
tommy_hashdyn previmportset; /**< Hashtable by prevhash of all the import blocks. Valid only if we are in a rehash state. */
|
||||
tommy_arrayblkof infoarr; /**< Block information array. */
|
||||
|
||||
/**
|
||||
* Cumulative time used for parity disks.
|
||||
*/
|
||||
uint64_t tick[LEV_MAX];
|
||||
|
||||
/**
|
||||
* Cumulative time used for computations.
|
||||
*/
|
||||
uint64_t tick_cpu;
|
||||
|
||||
/**
|
||||
* Last time used for time measure.
|
||||
*/
|
||||
uint64_t tick_last;
|
||||
|
||||
/**
|
||||
* Required size of the parity file, computed from the loaded state.
|
||||
*
|
||||
|
|
@ -251,6 +266,62 @@ void state_progress_stop(struct snapraid_state* state);
|
|||
*/
|
||||
void state_progress_restart(struct snapraid_state* state);
|
||||
|
||||
/**
|
||||
* Set the usage time as wasted one not counted.
|
||||
*/
|
||||
static inline void state_usage_waste(struct snapraid_state* state)
|
||||
{
|
||||
uint64_t now = tick();
|
||||
|
||||
state->tick_last = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the usage time for CPU.
|
||||
*/
|
||||
static inline void state_usage_cpu(struct snapraid_state* state)
|
||||
{
|
||||
uint64_t now = tick();
|
||||
|
||||
/* increment the time spent in computations */
|
||||
state->tick_cpu += now - state->tick_last;
|
||||
|
||||
state->tick_last = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the usage time for data disk.
|
||||
*/
|
||||
static inline void state_usage_disk(struct snapraid_state* state, struct snapraid_disk* disk)
|
||||
{
|
||||
uint64_t now = tick();
|
||||
|
||||
/* increment the time spent in the data disk */
|
||||
disk->tick += now - state->tick_last;
|
||||
|
||||
state->tick_last = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the usage time for parity disk.
|
||||
*/
|
||||
static inline void state_usage_parity(struct snapraid_state* state, unsigned level)
|
||||
{
|
||||
uint64_t now = tick();
|
||||
|
||||
assert(level < LEV_MAX);
|
||||
|
||||
/* increment the time spent in the parity disk */
|
||||
state->tick[level] += now - state->tick_last;
|
||||
|
||||
state->tick_last = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the stats of the usage time.
|
||||
*/
|
||||
void state_usage_print(struct snapraid_state* state);
|
||||
|
||||
/****************************************************************************/
|
||||
/* misc */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue