Skip to content

Commit

Permalink
fix benchmarks hit ratio display (#128)
Browse files Browse the repository at this point in the history
Was previously dividing hit by miss, should be dividing hit by total.
  • Loading branch information
paskal committed Apr 19, 2023
1 parent 04222e5 commit 8d9a62d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions 2q_test.go
Expand Up @@ -32,7 +32,7 @@ func Benchmark2Q_Rand(b *testing.B) {
}
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func Benchmark2Q_Freq(b *testing.B) {
Expand Down Expand Up @@ -63,7 +63,7 @@ func Benchmark2Q_Freq(b *testing.B) {
miss++
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func Test2Q_RandomOps(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions arc_test.go
Expand Up @@ -38,7 +38,7 @@ func BenchmarkARC_Rand(b *testing.B) {
}
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func BenchmarkARC_Freq(b *testing.B) {
Expand Down Expand Up @@ -69,7 +69,7 @@ func BenchmarkARC_Freq(b *testing.B) {
miss++
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func TestARC_RandomOps(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions lru_test.go
Expand Up @@ -32,7 +32,7 @@ func BenchmarkLRU_Rand(b *testing.B) {
}
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func BenchmarkLRU_Freq(b *testing.B) {
Expand Down Expand Up @@ -63,7 +63,7 @@ func BenchmarkLRU_Freq(b *testing.B) {
miss++
}
}
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss))
b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(hit+miss))
}

func TestLRU(t *testing.T) {
Expand Down

0 comments on commit 8d9a62d

Please sign in to comment.