-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding benchmarks for new pre-allocated buffer
S3 GetBucketPolicy benchmark: name old time/op new time/op delta GetBucketPolicy-12 12.7ms ± 2% 8.7ms ± 2% -31.60% (p=0.000 n=9+9) name old alloc/op new alloc/op delta GetBucketPolicy-12 83.4MB ± 0% 50.4MB ± 0% -39.60% (p=0.000 n=10+10) name old allocs/op new allocs/op delta GetBucketPolicy-12 256 ± 0% 216 ± 0% -15.49% (p=0.000 n=10+10) Schemas GetCodeBindingSource benchmarks: name old time/op new time/op delta GetCodeBindingSource-12 10.8ms ± 3% 7.4ms ± 4% -31.79% (p=0.000 n=10+10) name old alloc/op new alloc/op delta GetCodeBindingSource-12 70.8MB ± 0% 37.8MB ± 0% -46.64% (p=0.000 n=10+10) name old allocs/op new allocs/op delta GetCodeBindingSource-12 241 ± 0% 200 ± 0% -17.01% (p=0.000 n=10+10)
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package s3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package schemas |
56 changes: 56 additions & 0 deletions
56
service/internal/benchmark/schemas/get_code_binding_source_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)), | ||
} | ||
} |