Skip to content

Commit

Permalink
Add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrrat committed Jan 19, 2021
1 parent 9946fde commit c941afc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bench/jwe_benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bench_test

import (
"encoding/json"
"testing"

"github.com/lestrrat-go/jwx/jwe"
)

func BenchmarkJWE(b *testing.B) {
const s = `eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGeipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDbSv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaVmqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je81860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi6UklfCpIMfIjf7iGdXKHzg.48V1_ALb6US04U3b.5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6jiSdiwkIr3ajwQzaBtQD_A.XFBoMYUZodetZdvTiFvSkQ`

m, _ := jwe.Parse([]byte(s))

b.Run("MarshalJSON", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = json.Marshal(m)
}
})
}
34 changes: 34 additions & 0 deletions bench/jws_benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package bench_test

import (
"encoding/json"
"testing"

"github.com/lestrrat-go/jwx/jws"
)

func BenchmarkJWS(b *testing.B) {
s := `{
"payload": "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ",
"signatures":[
{
"header": {"kid":"2010-12-29"},
"protected":"eyJhbGciOiJSUzI1NiJ9",
"signature": "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"
},
{
"header": {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"},
"protected":"eyJhbGciOiJFUzI1NiJ9",
"signature": "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
}
]
}`

m, _ := jws.Parse([]byte(s))

b.Run("json.Marshal", func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = json.Marshal(m)
}
})
}

0 comments on commit c941afc

Please sign in to comment.