From 775b065858436fc90db1e975bebcf337eb87af41 Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Wed, 1 Feb 2023 13:29:19 +0100 Subject: [PATCH] test: add benchmark for UUID mapper (#1200) --- internal/relationtuple/uuid_mapping_test.go | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/relationtuple/uuid_mapping_test.go b/internal/relationtuple/uuid_mapping_test.go index 55ba97603..e7d03d9c2 100644 --- a/internal/relationtuple/uuid_mapping_test.go +++ b/internal/relationtuple/uuid_mapping_test.go @@ -349,3 +349,27 @@ func TestMapper(t *testing.T) { }) }) } + +func BenchmarkReadOnlyMapper(b *testing.B) { + ctx := context.Background() + reg := driver.NewSqliteTestRegistry(b, false, + driver.WithNamespaces([]*namespace.Namespace{{Name: "test"}})) + m := reg.ReadOnlyMapper() + + b.Run("FromTuple", func(b *testing.B) { + for i := 0; i < b.N; i++ { + _, err := m.FromTuple(ctx, &ketoapi.RelationTuple{ + Namespace: "test", + Object: "object", + Relation: "relation", + SubjectSet: &ketoapi.SubjectSet{ + Namespace: "test", + Object: "subject object", + Relation: "relation", + }, + }) + assert.NoError(b, err) + } + + }) +}