(b *testing.B)
| 916 | } |
| 917 | |
| 918 | func BenchmarkDatabaseGet1xRev(b *testing.B) { |
| 919 | base.DisableTestLogging(b) |
| 920 | |
| 921 | db, ctx := setupTestDB(b) |
| 922 | defer db.Close(ctx) |
| 923 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, b, db) |
| 924 | |
| 925 | body := Body{"foo": "bar", "rev": "1-a"} |
| 926 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc1", body, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 927 | |
| 928 | largeDoc := make([]byte, 1000000) |
| 929 | longBody := Body{"val": string(largeDoc), "rev": "1-a"} |
| 930 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc2", longBody, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 931 | |
| 932 | var shortWithAttachmentsDataBody Body |
| 933 | shortWithAttachmentsData := `{"test": true, "_attachments": {"hello.txt": {"data":"aGVsbG8gd29ybGQ="}}, "rev":"1-a"}` |
| 934 | _ = base.JSONUnmarshal([]byte(shortWithAttachmentsData), &shortWithAttachmentsDataBody) |
| 935 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc3", shortWithAttachmentsDataBody, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 936 | |
| 937 | b.Run("ShortLatest", func(b *testing.B) { |
| 938 | for n := 0; n < b.N; n++ { |
| 939 | _, _ = collection.Get1xRevBody(ctx, "doc1", "", false, nil) |
| 940 | } |
| 941 | }) |
| 942 | b.Run("LongLatest", func(b *testing.B) { |
| 943 | for n := 0; n < b.N; n++ { |
| 944 | _, _ = collection.Get1xRevBody(ctx, "doc2", "", false, nil) |
| 945 | } |
| 946 | }) |
| 947 | b.Run("ShortWithAttachmentsLatest", func(b *testing.B) { |
| 948 | for n := 0; n < b.N; n++ { |
| 949 | _, _ = collection.Get1xRevBody(ctx, "doc3", "", false, nil) |
| 950 | } |
| 951 | }) |
| 952 | |
| 953 | updateBody := Body{"rev": "2-a"} |
| 954 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc1", updateBody, []string{"2-a", "1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 955 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc2", updateBody, []string{"2-a", "1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 956 | _, _, _ = collection.PutExistingRevWithBody(ctx, "doc3", updateBody, []string{"2-a", "1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 957 | |
| 958 | b.Run("ShortOld", func(b *testing.B) { |
| 959 | for n := 0; n < b.N; n++ { |
| 960 | _, _ = collection.Get1xRevBody(ctx, "doc1", "1-a", false, nil) |
| 961 | } |
| 962 | }) |
| 963 | b.Run("LongOld", func(b *testing.B) { |
| 964 | for n := 0; n < b.N; n++ { |
| 965 | _, _ = collection.Get1xRevBody(ctx, "doc2", "1-a", false, nil) |
| 966 | } |
| 967 | }) |
| 968 | b.Run("ShortWithAttachmentsOld", func(b *testing.B) { |
| 969 | for n := 0; n < b.N; n++ { |
| 970 | _, _ = collection.Get1xRevBody(ctx, "doc3", "1-a", false, nil) |
| 971 | } |
| 972 | }) |
| 973 | } |
| 974 | |
| 975 | func BenchmarkDatabaseGetRev(b *testing.B) { |
nothing calls this directly
no test coverage detected