From c7cf5afd2ff20bbbf9291dc2aa6d7805d882e5c7 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 21 Jul 2021 12:05:24 +0300 Subject: [PATCH] [#149] Add benchmarks Signed-off-by: Denis Kirillov --- api/errors_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 api/errors_test.go diff --git a/api/errors_test.go b/api/errors_test.go new file mode 100644 index 000000000..17e272e8e --- /dev/null +++ b/api/errors_test.go @@ -0,0 +1,26 @@ +package api + +import ( + "errors" + "testing" +) + +func BenchmarkErrCode(b *testing.B) { + err := GetAPIError(ErrNoSuchKey) + + for i := 0; i < b.N; i++ { + if IsS3Error(err, ErrNoSuchKey) { + _ = err + } + } +} + +func BenchmarkErrorsIs(b *testing.B) { + err := GetAPIError(ErrNoSuchKey) + + for i := 0; i < b.N; i++ { + if errors.Is(err, GetAPIError(ErrNoSuchKey)) { + _ = err + } + } +}