-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add compacted array benchmark tests #47
Conversation
array/benchmark_compact_test.go
Outdated
index := make([]uint32, 0, maxIdx) | ||
|
||
for i := uint32(0); i < maxIdx; i++ { | ||
if i%idxDis == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 后面 i += idxDis
好不...
Dis开头的单词太多了...这里用Step感觉通俗简短点
array/benchmark_compact_test.go
Outdated
} | ||
|
||
func makeDisIndexes(maxIdx, idxDis uint32) []uint32 { | ||
index := make([]uint32, 0, maxIdx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之后考虑优化下数组中数据特别稀疏的情况. 然后...等距的插入可能有些特殊性. 不方便日后做测试, 这里把间隔打乱下如何? 只保证平均间隔是idxDis. 实际每个间隔调整成idxDis*0.8 ~ idxDis * 1.2
之间
array/benchmark_compact_test.go
Outdated
return rss2 - rss1 | ||
} | ||
|
||
func makeDiscrete(max uint32) []uint32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discrete是啥意思在这里?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
离散的step
array/benchmark_compact_test.go
Outdated
|
||
eltCnt := uint32(len(indexes)) | ||
|
||
fmt.Printf("%-10d%-10d%-10d%-10.3f\n", eltSize, eltCnt, idxDis, overhead) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
数字都用右对齐吧. 容易比较...
array/compactOverhead.md
Outdated
8 2 39602 1024 8155088 7963 16 497.688 | ||
8 2 64079 1024 12480560 12188 16 761.750 | ||
eltSize eltCount idxDis Overhead | ||
1 65536 1 1.165 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
希望增加1列load-factor = 实际数据个数 / 最大id
, 表示这个数组的稀疏的程度: 0~1;
一般这个比较容易看懂. idxDis也表示同样的信息,但还得换算一下.
overhead应该是额外内存开销的比例, 这里之前设置成总的开销 / 有效数据了.
overhead打印成+12%
的形式可能更容易看懂.
array/compactOverhead.md
Outdated
1 9 8153 1382.111 | ||
1 5 14863 2487.800 | ||
1 3 27093 3461.000 | ||
1 2 49388 4935.500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉idxDis还有点多, 手动配置几个有代表性的load-factor咋样? 对我来说关心的几个load-factor 是 1.0(满的) 0.5(半满), 0.2, 0.1, 0.01, 0.001
.
array/benchmark_compact_test.go
Outdated
} | ||
|
||
func BenchmarkMemOverhead(b *testing.B) { | ||
var cases = []struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
独立的只bench不做表格输出的函数还可以方便的在xx_test里调用吗? 想想那里如果能统一对所有东西bench下好像也不错...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
独立的bench是一个func Testxxx(t *testing.B)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是一个func BenchXXX
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样?
func BenchX1(t *testing.B) {
}
func BenchX2(t *testing.B) {
}
func BenchX3(t *testing.B) {
}
func BenchXXX(t *testing.B) {
t.Run("A=1", BenchX1)
t.Run("A=2", BenchX2)
t.Run("A=3", BenchX3)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额...当面说吧...
33bd084
to
a0110f6
Compare
array/benchmark_compact_test.go
Outdated
dataAvgSize := uint64(eltSize) * uint64(eltCnt) | ||
actAvgSize := actSize / uint64(caCnt) | ||
|
||
overHead := float64(actAvgSize) / float64(dataAvgSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉overhead的定义是float64(actAvgSize) / float64(dataAvgSize) - 1
a0110f6
to
10463c2
Compare
10463c2
to
f716460
Compare
Description
add compacted array memory benchmark tests
Fixes #12
Type of change
Checklist: