func findOne(coll *mongo.Collection, t *testing.T) { ss := &smallStruct{PER_TRIAL / 2} obj, err := mongo.Marshal(ss) if err != nil { t.Errorf("findOne Marshal: %v\n", err) } for i := 0; i < PER_TRIAL; i++ { _, err = coll.FindOne(obj) if err != nil { t.Errorf("findOne FindOne: %v\n", err) } } }
func singleInsertMedium(coll *mongo.Collection, t *testing.T) { ms := &mediumStruct{5, 5.05, false, []string{"test", "benchmark"}, 0} for i := 0; i < PER_TRIAL; i++ { ms.X = i obj, err := mongo.Marshal(ms) if err != nil { t.Errorf("singleInsertMedium Marshal: %v\n", err) } err = coll.Insert(obj) if err != nil { t.Errorf("singleInsertMedium Insert: %v\n", err) } } }
func singleInsertSmall(coll *mongo.Collection, t *testing.T) { ss := &smallStruct{0} for i := 0; i < PER_TRIAL; i++ { ss.X = i obj, err := mongo.Marshal(ss) if err != nil { t.Errorf("singleInsertSmall Marshal: %v\n", err) } err = coll.Insert(obj) if err != nil { t.Errorf("singleInsertSmall Insert: %v\n", err) } } }
func singleInsertLarge(coll *mongo.Collection, t *testing.T) { base_words := []string{"10gen", "web", "open", "source", "application", "paas", "platform-as-a-service", "technology", "helps", "developers", "focus", "building", "mongodb", "mongo", } words := make([]string, 280) for i := 0; i < 20; i++ { for k, word := range base_words { words[i+k] = word } } ls := &largeStruct{"http://www.example.com/test-me", 6743, time.UTC(), map[string]string{"description": "i am a long description string", "author": "Holly Man", "dynamically_created_meta_tag": "who know\n what", }, map[string]int{"counted_tags": 3450, "no_of_js_attached": 10, "no_of_images": 6, }, words, 0, } for i := 0; i < PER_TRIAL; i++ { ls.X = i obj, err := mongo.Marshal(ls) if err != nil { t.Errorf("singleInsertLarge Marshal: %v", err) } err = coll.Insert(obj) if err != nil { t.Errorf("singleInsertLarge Insert: %v", err) } } }