diff --git a/service/internal/benchmark/go.mod b/service/internal/benchmark/go.mod index 72028c2faaf..4ed083401c0 100644 --- a/service/internal/benchmark/go.mod +++ b/service/internal/benchmark/go.mod @@ -7,6 +7,8 @@ require ( github.com/aws/aws-sdk-go-v2 v1.13.0 github.com/aws/aws-sdk-go-v2/service/dynamodb v1.13.0 github.com/aws/aws-sdk-go-v2/service/lexruntimeservice v1.10.0 + github.com/aws/aws-sdk-go-v2/service/s3 v1.24.0 // indirect + github.com/aws/aws-sdk-go-v2/service/schemas v1.12.0 // indirect github.com/aws/smithy-go v1.10.0 ) @@ -23,3 +25,7 @@ replace github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding => ../../. replace github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery => ../../../service/internal/endpoint-discovery/ replace github.com/aws/aws-sdk-go-v2/service/lexruntimeservice => ../../../service/lexruntimeservice/ + +replace github.com/aws/aws-sdk-go-v2/service/s3 => ../../../service/s3/ + +replace github.com/aws/aws-sdk-go-v2/service/schemas => ../../../service/schemas/ diff --git a/service/internal/benchmark/go.sum b/service/internal/benchmark/go.sum index 9e455092086..10b3894c484 100644 --- a/service/internal/benchmark/go.sum +++ b/service/internal/benchmark/go.sum @@ -1,5 +1,15 @@ github.com/aws/aws-sdk-go v1.34.33 h1:ymkFm0rNPEOlgjyX3ojEd4zqzW6kGICBkqWs7LqgHtU= github.com/aws/aws-sdk-go v1.34.33/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.2.0 h1:scBthy70MB3m4LCMFaBcmYCyR2XWOz6MxSfdSu/+fQo= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.2.0/go.mod h1:oZHzg1OVbuCiRTY0oRPM+c2HQvwnFCGJwKeSqqAJ/yM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0 h1:4QAOB3KrvI1ApJK14sliGr3Ie2pjyvNypn/lfzDHfUw= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0/go.mod h1:K/qPe6AP2TGYv4l6n7c88zh9jWBDf6nHhvg1fx/EWfU= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.11.0 h1:XAe+PDnaBELHr25qaJKfB415V4CKFWE8H+prUreql8k= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.11.0/go.mod h1:RMlgnt1LbOT2BxJ3cdw+qVz7KL84714LFkWtF6sLI7A= +github.com/aws/aws-sdk-go-v2/service/s3 v1.24.0 h1:REKac2iT0HYxUSzqOSuncnmsZnE3m4MlGfo1dOUN3vg= +github.com/aws/aws-sdk-go-v2/service/s3 v1.24.0/go.mod h1:oIUXg/5F0x0gy6nkwEnlxZboueddwPEKO6Xl+U6/3a0= +github.com/aws/aws-sdk-go-v2/service/schemas v1.12.0 h1:RfqnMV7sOkLxqUjltYY2FdsNaxuzqDrmp89/E9Jyj70= +github.com/aws/aws-sdk-go-v2/service/schemas v1.12.0/go.mod h1:znm7/t+tVXzCzcS3UOLaMsaB9xNkWIT/jvRUNRLB4A0= github.com/aws/smithy-go v1.10.0 h1:gsoZQMNHnX+PaghNw4ynPsyGP7aUCqx5sY2dlPQsZ0w= github.com/aws/smithy-go v1.10.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= diff --git a/service/internal/benchmark/s3/doc.go b/service/internal/benchmark/s3/doc.go new file mode 100644 index 00000000000..3ed7f97237d --- /dev/null +++ b/service/internal/benchmark/s3/doc.go @@ -0,0 +1 @@ +package s3 diff --git a/service/internal/benchmark/s3/get_bucket_policy_test.go b/service/internal/benchmark/s3/get_bucket_policy_test.go new file mode 100644 index 00000000000..b568fc576f0 --- /dev/null +++ b/service/internal/benchmark/s3/get_bucket_policy_test.go @@ -0,0 +1,66 @@ +package s3 + +import ( + "context" + "io" + "io/ioutil" + "net/http" + "strings" + "testing" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/s3" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +func init() { + var s strings.Builder + io.Copy(&s, io.LimitReader(byteReader('a'), 1024*1024*12)) + largeStringPayload = s.String() +} + +type byteReader byte + +func (b byteReader) Read(p []byte) (int, error) { + for i := 0; i < len(p); i++ { + p[i] = byte(b) + } + return len(p), nil +} + +var largeStringPayload string + +func BenchmarkGetBucketPolicy(b *testing.B) { + client := s3.New(s3.Options{ + Region: "us-west-2", + HTTPClient: smithyhttp.ClientDoFunc( + func(r *http.Request) (*http.Response, error) { + return newGetBucketPolicyHTTPResponse(largeStringPayload), nil + }), + }) + + ctx := context.Background() + params := s3.GetBucketPolicyInput{ + Bucket: aws.String("fooBucket"), + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := client.GetBucketPolicy(ctx, ¶ms) + if err != nil { + b.Fatalf("failed to send: %v", err) + } + } + +} + +func newGetBucketPolicyHTTPResponse(payload string) *http.Response { + return &http.Response{ + StatusCode: 200, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + ContentLength: int64(len(payload)), + Body: ioutil.NopCloser(strings.NewReader(payload)), + } +} diff --git a/service/internal/benchmark/schemas/doc.go b/service/internal/benchmark/schemas/doc.go new file mode 100644 index 00000000000..faeaab64e51 --- /dev/null +++ b/service/internal/benchmark/schemas/doc.go @@ -0,0 +1 @@ +package schemas diff --git a/service/internal/benchmark/schemas/get_code_binding_source_test.go b/service/internal/benchmark/schemas/get_code_binding_source_test.go new file mode 100644 index 00000000000..05b1f1222e2 --- /dev/null +++ b/service/internal/benchmark/schemas/get_code_binding_source_test.go @@ -0,0 +1,56 @@ +package schemas + +import ( + "bytes" + "context" + "io/ioutil" + "net/http" + "testing" + + "github.com/aws/aws-sdk-go-v2/service/schemas" + "github.com/aws/smithy-go/ptr" + smithyhttp "github.com/aws/smithy-go/transport/http" +) + +func init() { + largeBytePayload = make([]byte, 1024*1024*12) +} + +var largeBytePayload []byte + +func BenchmarkGetCodeBindingSource(b *testing.B) { + client := schemas.New(schemas.Options{ + Region: "us-west-2", + HTTPClient: smithyhttp.ClientDoFunc( + func(r *http.Request) (*http.Response, error) { + return newGetCodeBindingSourceHTTPResponse(largeBytePayload), nil + }), + }) + + ctx := context.Background() + params := schemas.GetCodeBindingSourceInput{ + Language: ptr.String("fooLanguage"), + RegistryName: ptr.String("fooRegistry"), + SchemaName: ptr.String("fooSchema"), + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := client.GetCodeBindingSource(ctx, ¶ms) + if err != nil { + b.Fatalf("failed to send: %v", err) + } + } + +} + +func newGetCodeBindingSourceHTTPResponse(payload []byte) *http.Response { + return &http.Response{ + StatusCode: 200, + Header: map[string][]string{ + "Content-Type": {"application/octet-stream"}, + }, + ContentLength: int64(len(payload)), + Body: ioutil.NopCloser(bytes.NewReader(payload)), + } +}