@@ -87,7 +87,7 @@ func BenchmarkV1BulkInsert100KDocs(b *testing.B) {
8787}
8888
8989func bulkRead (b * testing.B , docSize int ) {
90- db , col := setup (b )
90+ _ , col := setup (b )
9191
9292 // -----------------------------
9393 // Prepare and insert documents
@@ -110,31 +110,24 @@ func bulkRead(b *testing.B, docSize int) {
110110 require .NoError (b , err )
111111
112112 // -----------------------------------------
113- // Sub-benchmark 1: Read entire collection
113+ // Sub-benchmark 1: Read entire collection using ReadDocuments
114114 // -----------------------------------------
115115 b .Run ("ReadAllDocsOnce" , func (b * testing.B ) {
116- query := fmt .Sprintf ("FOR d IN %s RETURN d" , col .Name ())
116+ // Prepare keys for reading
117+ keys := make ([]string , docSize )
118+ for j := 0 ; j < docSize ; j ++ {
119+ keys [j ] = fmt .Sprintf ("doc_%d" , j )
120+ }
117121
118122 b .ResetTimer ()
119123 for i := 0 ; i < b .N ; i ++ {
120- cursor , err := db .Query (ctx , query , nil )
124+ readDocs := make ([]TestDoc , docSize )
125+ _ , _ , err := col .ReadDocuments (ctx , keys , readDocs )
121126 require .NoError (b , err )
122127
123- count := 0
124- for {
125- var doc TestDoc
126- _ , err := cursor .ReadDocument (ctx , & doc )
127- if driver .IsNoMoreDocuments (err ) {
128- break
129- }
130- require .NoError (b , err )
131- count ++
132- }
133- // require.Equal(b, docSize, count, "expected to read all documents")
134- _ = cursor .Close ()
135128 // sanity check
136- if count != docSize {
137- b .Fatalf ("expected to read %d docs, got %d" , docSize , count )
129+ if len ( readDocs ) != docSize {
130+ b .Fatalf ("expected to read %d docs, got %d" , docSize , len ( readDocs ) )
138131 }
139132 }
140133 })
0 commit comments