diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-10 21:06:00 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-10 21:06:00 +0100 |
commit | 94a0b2783aa58b646260232ecfa3ff93f9b97d6d (patch) | |
tree | e0f356e7df1c2894fdbf15162d8467b42a062b21 /lib/sqfs/block_processor | |
parent | 6a7a7aaa4c7c715577d9649657412f99c06e1a95 (diff) |
Add run time statistics to the block writer and processor
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor')
-rw-r--r-- | lib/sqfs/block_processor/common.c | 11 | ||||
-rw-r--r-- | lib/sqfs/block_processor/fileapi.c | 8 | ||||
-rw-r--r-- | lib/sqfs/block_processor/internal.h | 2 |
3 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c index fe9773e..bedc923 100644 --- a/lib/sqfs/block_processor/common.c +++ b/lib/sqfs/block_processor/common.c @@ -29,6 +29,9 @@ int block_processor_init(sqfs_block_processor_t *proc, size_t max_block_size, proc->cmp = cmp; proc->frag_tbl = tbl; proc->wr = wr; + + memset(&proc->stats, 0, sizeof(proc->stats)); + proc->stats.size = sizeof(proc->stats); return 0; } @@ -149,6 +152,7 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag, proc->frag_block->index = index; proc->frag_block->flags = SQFS_BLK_FRAGMENT_BLOCK; + proc->stats.frag_block_count += 1; } err = sqfs_frag_table_add_tail_end(proc->frag_tbl, @@ -170,6 +174,7 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag, proc->frag_block->flags |= (frag->flags & SQFS_BLK_DONT_COMPRESS); proc->frag_block->size += frag->size; + proc->stats.actual_frag_count += 1; return 0; fail: free(*blk_out); @@ -184,3 +189,9 @@ out_duplicate: } return 0; } + +const sqfs_block_processor_stats_t +*sqfs_block_processor_get_stats(const sqfs_block_processor_t *proc) +{ + return &proc->stats; +} diff --git a/lib/sqfs/block_processor/fileapi.c b/lib/sqfs/block_processor/fileapi.c index 9e59c1d..dee1d5e 100644 --- a/lib/sqfs/block_processor/fileapi.c +++ b/lib/sqfs/block_processor/fileapi.c @@ -69,15 +69,21 @@ static int flush_block(sqfs_block_processor_t *proc, sqfs_block_t *block) proc->inode->num_file_blocks += 1; proc->inode->extra[block->index] = 0; free(block); + + proc->stats.sparse_block_count += 1; return 0; } if (block->size < proc->max_block_size && !(block->flags & SQFS_BLK_DONT_FRAGMENT)) { block->flags |= SQFS_BLK_IS_FRAGMENT; + + proc->stats.total_frag_count += 1; } else { proc->inode->num_file_blocks += 1; proc->blk_flags &= ~SQFS_BLK_FIRST_BLOCK; + + proc->stats.data_block_count += 1; } return enqueue_block(proc, block); @@ -121,6 +127,8 @@ int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data, size -= diff; proc->blk_current->size += diff; data = (const char *)data + diff; + + proc->stats.input_bytes_read += diff; } if (proc->blk_current != NULL && diff --git a/lib/sqfs/block_processor/internal.h b/lib/sqfs/block_processor/internal.h index 09e879b..dcf8a09 100644 --- a/lib/sqfs/block_processor/internal.h +++ b/lib/sqfs/block_processor/internal.h @@ -71,6 +71,8 @@ struct sqfs_block_processor_t { const sqfs_block_hooks_t *hooks; void *user_ptr; + sqfs_block_processor_stats_t stats; + /* file API */ sqfs_inode_generic_t *inode; sqfs_block_t *blk_current; |