-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigner_bench_test.go
42 lines (34 loc) · 928 Bytes
/
signer_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sigv4
import (
"testing"
"time"
)
func BenchmarkHTTPSigner_Sign(b *testing.B) {
b.ReportAllocs()
signer, err := New(WithCredential("AKID", "SECRET", "SESSION"),
WithRegionService("us-east-1", "dynamodb"))
if err != nil {
b.Fatalf("unexpected error: %v", err)
}
req, bodyHash := buildRequest("dynamodb", "us-east-1", "{}")
t := NewTime(time.Now())
for i := 0; i < b.N; i++ {
signer.Sign(req, bodyHash, t)
}
}
func BenchmarkHTTPSigner_Presign(b *testing.B) {
b.ReportAllocs()
signer, err := New(WithCredential("AKID", "SECRET", "SESSION"),
WithRegionService("us-east-1", "dynamodb"))
if err != nil {
b.Fatalf("unexpected error: %v", err)
}
req, bodyHash := buildRequest("dynamodb", "us-east-1", "{}")
query := req.URL.Query()
query.Set("X-Amz-Expires", "5")
req.URL.RawQuery = query.Encode()
t := NewTime(time.Now())
for i := 0; i < b.N; i++ {
signer.Presign(req, bodyHash, t)
}
}