-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_test.go
More file actions
39 lines (35 loc) · 941 Bytes
/
benchmark_test.go
File metadata and controls
39 lines (35 loc) · 941 Bytes
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
package main
import (
"context"
"database/sql"
"strconv"
"testing"
_ "github.com/mattn/go-sqlite3"
"github.com/ory/fosite"
)
func BenchmarkLoggingAdapterCreateToken(b *testing.B) {
adapter := NewLoggingAdapter(NewInMemoryStore())
req := &fosite.Request{}
for i := 0; i < b.N; i++ {
adapter.CreateToken(context.Background(), "access_token", "sig"+strconv.Itoa(i), "c1", req)
}
}
func BenchmarkLegacyDBCreateToken(b *testing.B) {
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
b.Fatal(err)
}
stmts := []string{
`CREATE TABLE tokens (signature TEXT PRIMARY KEY, client_id TEXT, token_type TEXT, data BLOB, revoked_at TIMESTAMP)`,
}
for _, s := range stmts {
if _, err := db.Exec(s); err != nil {
b.Fatal(err)
}
}
adapter := NewLegacyDBAdapter(db)
req := []byte("data")
for i := 0; i < b.N; i++ {
adapter.CreateToken(context.Background(), "access_token", "sig"+strconv.Itoa(i), "c1", req)
}
}