mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
core/state: add cache hit rate
This commit is contained in:
parent
49b0050d18
commit
70c0699655
1 changed files with 11 additions and 1 deletions
|
|
@ -95,7 +95,17 @@ type ReaderStats struct {
|
||||||
|
|
||||||
// String implements fmt.Stringer, returning string format statistics.
|
// String implements fmt.Stringer, returning string format statistics.
|
||||||
func (s ReaderStats) String() string {
|
func (s ReaderStats) String() string {
|
||||||
return fmt.Sprintf("account (hit: %d, miss: %d), storage (hit: %d, miss: %d)", s.AccountHit, s.AccountMiss, s.StorageHit, s.StorageMiss)
|
var (
|
||||||
|
accountRate float64
|
||||||
|
storageRate float64
|
||||||
|
)
|
||||||
|
if s.AccountHit > 0 {
|
||||||
|
accountRate = float64(s.AccountHit) / float64(s.AccountHit+s.AccountMiss) * 100
|
||||||
|
}
|
||||||
|
if s.StorageHit > 0 {
|
||||||
|
storageRate = float64(s.StorageHit) / float64(s.StorageHit+s.StorageMiss) * 100
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("account (hit: %d, miss: %d, rate: %.2f), storage (hit: %d, miss: %d, rate: %.2f)", s.AccountHit, s.AccountMiss, accountRate, s.StorageHit, s.StorageMiss, storageRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReaderWithStats wraps the additional method to retrieve the reader statistics from.
|
// ReaderWithStats wraps the additional method to retrieve the reader statistics from.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue