1// Copyright 2018 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// This file contains information for gathering Blobfs metrics. 6 7#include <stdio.h> 8 9#include <blobfs/metrics.h> 10#include <lib/fzl/time.h> 11#include <lib/zx/time.h> 12 13namespace blobfs { 14namespace { 15 16size_t TicksToMs(const zx::ticks& ticks) { 17 return fzl::TicksToNs(ticks) / zx::msec(1); 18} 19 20} // namespace 21 22void BlobfsMetrics::Dump() const { 23 constexpr uint64_t mb = 1 << 20; 24 25 printf("Allocation Info:\n"); 26 printf(" Allocated %zu blobs (%zu MB) in %zu ms\n", blobs_created, 27 blobs_created_total_size / mb, 28 TicksToMs(total_allocation_time_ticks)); 29 printf("Writeback Info:\n"); 30 printf(" (Client) Wrote %zu MB of data and %zu MB of merkle trees\n", 31 data_bytes_written / mb, merkle_bytes_written / mb); 32 printf(" (Client) Enqueued writeback in %zu ms, made merkle tree in %zu ms\n", 33 TicksToMs(total_write_enqueue_time_ticks), 34 TicksToMs(total_merkle_generation_time_ticks)); 35 printf(" (Writeback Thread) Wrote %zu MB of data in %zu ms\n", 36 total_writeback_bytes_written / mb, 37 TicksToMs(total_writeback_time_ticks)); 38 printf("Lookup Info:\n"); 39 printf(" Opened %zu blobs (%zu MB)\n", blobs_opened, 40 blobs_opened_total_size / mb); 41 printf(" Verified %zu blobs (%zu MB data, %zu MB merkle)\n", 42 blobs_verified, blobs_verified_total_size_data / mb, 43 blobs_verified_total_size_merkle / mb); 44 printf(" Spent %zu ms reading %zu MB from disk, %zu ms verifying\n", 45 TicksToMs(total_read_from_disk_time_ticks), 46 bytes_read_from_disk / mb, 47 TicksToMs(total_verification_time_ticks)); 48} 49 50} // namespace blobfs 51