forked from mongodb/mongo-go-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bson_reader.go
39 lines (31 loc) · 932 Bytes
/
bson_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package benchmark
import (
"context"
"errors"
)
func bsonReaderDecoding(ctx context.Context, tm TimerManager, iters, numKeys int, source string) error {
doc, err := loadSourceReader(getProjectRoot(), perfDataDir, bsonDataDir, source)
if err != nil {
return err
}
tm.ResetTimer()
for i := 0; i < iters; i++ {
keys, err := doc.Keys(true)
if err != nil {
return err
}
if len(keys) != numKeys {
return errors.New("reader parsing error")
}
}
return nil
}
func BSONFlatReaderDecoding(ctx context.Context, tm TimerManager, iters int) error {
return bsonReaderDecoding(ctx, tm, iters, 145, flatBSONData)
}
func BSONDeepReaderDecoding(ctx context.Context, tm TimerManager, iters int) error {
return bsonReaderDecoding(ctx, tm, iters, 126, deepBSONData)
}
func BSONFullReaderDecoding(ctx context.Context, tm TimerManager, iters int) error {
return bsonReaderDecoding(ctx, tm, iters, 145, fullBSONData)
}