mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-14 08:52:44 +00:00
9c6e3c89a5
* fix js scoping issue * add external libraries (they were offline too often) * new compiled scripts and css * new fixes in the binary * vendor update * change js source * remove needless variable * removed more needless variables
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package s3
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
"github.com/aws/aws-sdk-go/awstesting/unit"
|
|
)
|
|
|
|
func BenchmarkPresign_GetObject(b *testing.B) {
|
|
sess := unit.Session
|
|
svc := New(sess)
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
req, _ := svc.GetObjectRequest(&GetObjectInput{
|
|
Bucket: aws.String("mock-bucket"),
|
|
Key: aws.String("mock-key"),
|
|
})
|
|
|
|
u, h, err := req.PresignRequest(15 * time.Minute)
|
|
if err != nil {
|
|
b.Fatalf("expect no error, got %v", err)
|
|
}
|
|
if len(u) == 0 {
|
|
b.Fatalf("expect url, got none")
|
|
}
|
|
if len(h) != 0 {
|
|
b.Fatalf("no signed headers, got %v", h)
|
|
}
|
|
}
|
|
}
|
|
|
|
func BenchmarkPresign_PutObject(b *testing.B) {
|
|
sess := unit.Session
|
|
svc := New(sess)
|
|
|
|
body := make([]byte, 1024*1024*20)
|
|
for i := 0; i < b.N; i++ {
|
|
req, _ := svc.PutObjectRequest(&PutObjectInput{
|
|
Bucket: aws.String("mock-bucket"),
|
|
Key: aws.String("mock-key"),
|
|
Body: bytes.NewReader(body),
|
|
})
|
|
|
|
u, h, err := req.PresignRequest(15 * time.Minute)
|
|
if err != nil {
|
|
b.Fatalf("expect no error, got %v", err)
|
|
}
|
|
if len(u) == 0 {
|
|
b.Fatalf("expect url, got none")
|
|
}
|
|
if len(h) == 0 {
|
|
b.Fatalf("expect signed header, got none")
|
|
}
|
|
}
|
|
}
|