summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
index 6ac429d8b..8635e34d1 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/bulk_delete_request_test.go
@@ -15,23 +15,23 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
}{
// #0
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1"}}`,
},
},
// #1
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1").Parent("2"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Parent("2"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_parent":"2","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1","parent":"2"}}`,
},
},
// #2
{
- Request: NewBulkDeleteRequest().Index("index1").Type("tweet").Id("1").Routing("3"),
+ Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Routing("3"),
Expected: []string{
- `{"delete":{"_id":"1","_index":"index1","_routing":"3","_type":"tweet"}}`,
+ `{"delete":{"_index":"index1","_type":"doc","_id":"1","routing":"3"}}`,
},
},
}
@@ -58,11 +58,22 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
var bulkDeleteRequestSerializationResult string
func BenchmarkBulkDeleteRequestSerialization(b *testing.B) {
- r := NewBulkDeleteRequest().Index(testIndexName).Type("tweet").Id("1")
+ b.Run("stdlib", func(b *testing.B) {
+ r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(false))
+ })
+ b.Run("easyjson", func(b *testing.B) {
+ r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
+ benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(true))
+ })
+}
+
+func benchmarkBulkDeleteRequestSerialization(b *testing.B, r *BulkDeleteRequest) {
var s string
for n := 0; n < b.N; n++ {
s = r.String()
r.source = nil // Don't let caching spoil the benchmark
}
bulkDeleteRequestSerializationResult = s // ensure the compiler doesn't optimize
+ b.ReportAllocs()
}