From db1dd2bf6a8a4318eb0d17c863ae0738685ebc5d Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Fri, 15 Sep 2023 18:23:02 +0300 Subject: [PATCH] update delete benchmarks --- arangodb/arangodb_test.go | 7 +++---- azureblob/azureblob_test.go | 7 +++---- badger/badger_test.go | 5 ++--- bbolt/bbolt_test.go | 5 ++--- coherence/coherence_test.go | 7 +++---- couchbase/couchbase_test.go | 7 +++---- dynamodb/dynamodb_test.go | 39 +++++++++++++++++++++++++++++++++++++ etcd/etcd_test.go | 7 +++---- memcache/memcache_test.go | 7 +++---- memory/memory_test.go | 7 +++---- minio/minio_test.go | 7 +++---- mongodb/mongodb_test.go | 7 +++---- mssql/mssql_test.go | 7 +++---- mysql/mysql_test.go | 7 +++---- pebble/pebble_test.go | 7 +++---- postgres/postgres_test.go | 7 +++---- redis/redis_test.go | 25 +++++++++++------------- ristretto/ristretto_test.go | 9 ++++----- rueidis/rueidis_test.go | 16 +++++++-------- s3/s3_test.go | 7 +++---- sqlite3/sqlite3_test.go | 5 ++--- 21 files changed, 109 insertions(+), 93 deletions(-) diff --git a/arangodb/arangodb_test.go b/arangodb/arangodb_test.go index 9ce6ae67..ef0ef4f1 100644 --- a/arangodb/arangodb_test.go +++ b/arangodb/arangodb_test.go @@ -158,14 +158,13 @@ func Benchmark_ArangoDB_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_ArangoDB_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_ArangoDB_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/azureblob/azureblob_test.go b/azureblob/azureblob_test.go index 59da61b9..2b5b1902 100644 --- a/azureblob/azureblob_test.go +++ b/azureblob/azureblob_test.go @@ -163,14 +163,13 @@ func Benchmark_AzureBlob_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_AzureBlob_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_AzureBlob_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/badger/badger_test.go b/badger/badger_test.go index 2f471a98..3e90ae9e 100644 --- a/badger/badger_test.go +++ b/badger/badger_test.go @@ -148,13 +148,12 @@ func Benchmark_Badger_Get(b *testing.B) { } func Benchmark_Badger_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/bbolt/bbolt_test.go b/bbolt/bbolt_test.go index 7ac196af..e53918c9 100644 --- a/bbolt/bbolt_test.go +++ b/bbolt/bbolt_test.go @@ -137,13 +137,12 @@ func Benchmark_Bbolt_Get(b *testing.B) { } func Benchmark_Bbolt_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/coherence/coherence_test.go b/coherence/coherence_test.go index b093b3a5..009fecd2 100644 --- a/coherence/coherence_test.go +++ b/coherence/coherence_test.go @@ -216,14 +216,13 @@ func Benchmark_Coherence_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Coherence_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Coherence_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/couchbase/couchbase_test.go b/couchbase/couchbase_test.go index 8af3728c..fa8cc6b2 100644 --- a/couchbase/couchbase_test.go +++ b/couchbase/couchbase_test.go @@ -129,16 +129,15 @@ func Benchmark_Couchbase_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Couchbase_Delete(b *testing.B) { +func Benchmark_Couchbase_SetAndDelete(b *testing.B) { testStore := newTestStore(b) - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/dynamodb/dynamodb_test.go b/dynamodb/dynamodb_test.go index 704b344b..808f1243 100644 --- a/dynamodb/dynamodb_test.go +++ b/dynamodb/dynamodb_test.go @@ -115,3 +115,42 @@ func Test_DynamoDB_Close(t *testing.T) { func Test_DynamoDB_Conn(t *testing.T) { require.True(t, testStore.Conn() != nil) } + +func Benchmark_DynamoDB_Set(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + + var err error + for i := 0; i < b.N; i++ { + err = testStore.Set("john", []byte("doe"), 0) + } + + require.NoError(b, err) +} + +func Benchmark_DynamoDB_Get(b *testing.B) { + err := testStore.Set("john", []byte("doe"), 0) + require.NoError(b, err) + + b.ReportAllocs() + b.ResetTimer() + + for i := 0; i < b.N; i++ { + _, err = testStore.Get("john") + } + + require.NoError(b, err) +} + +func Benchmark_DynamoDB_SetAndDelete(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() + + var err error + for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) + err = testStore.Delete("john") + } + + require.NoError(b, err) +} diff --git a/etcd/etcd_test.go b/etcd/etcd_test.go index bcbcf20e..7232f864 100644 --- a/etcd/etcd_test.go +++ b/etcd/etcd_test.go @@ -118,14 +118,13 @@ func Benchmark_Etcd_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Etcd_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Etcd_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/memcache/memcache_test.go b/memcache/memcache_test.go index 5947b0c2..479fa954 100644 --- a/memcache/memcache_test.go +++ b/memcache/memcache_test.go @@ -157,14 +157,13 @@ func Benchmark_Memcache_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Memcache_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Memcache_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/memory/memory_test.go b/memory/memory_test.go index bcb100e1..c5f75a24 100644 --- a/memory/memory_test.go +++ b/memory/memory_test.go @@ -174,14 +174,13 @@ func Benchmark_Memory_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Memory_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Memory_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/minio/minio_test.go b/minio/minio_test.go index 683c985e..9740dfb4 100644 --- a/minio/minio_test.go +++ b/minio/minio_test.go @@ -220,14 +220,13 @@ func Benchmark_Minio_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Minio_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Minio_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/mongodb/mongodb_test.go b/mongodb/mongodb_test.go index 36f3fe13..a12d1f50 100644 --- a/mongodb/mongodb_test.go +++ b/mongodb/mongodb_test.go @@ -157,14 +157,13 @@ func Benchmark_MongoDB_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_MongoDB_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_MongoDB_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/mssql/mssql_test.go b/mssql/mssql_test.go index 6cdf1783..bb209caf 100644 --- a/mssql/mssql_test.go +++ b/mssql/mssql_test.go @@ -200,14 +200,13 @@ func Benchmark_MSSQL_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_MSSQL_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_MSSQL_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/mysql/mysql_test.go b/mysql/mysql_test.go index 66a74c34..6bb4eb6c 100644 --- a/mysql/mysql_test.go +++ b/mysql/mysql_test.go @@ -216,14 +216,13 @@ func Benchmark_MYSQL_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_MYSQL_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_MYSQL_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/pebble/pebble_test.go b/pebble/pebble_test.go index 505645ac..2b8a34e6 100644 --- a/pebble/pebble_test.go +++ b/pebble/pebble_test.go @@ -132,14 +132,13 @@ func Benchmark_Pebble_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Pebble_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Pebble_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/postgres/postgres_test.go b/postgres/postgres_test.go index 6057e721..0a226522 100644 --- a/postgres/postgres_test.go +++ b/postgres/postgres_test.go @@ -197,14 +197,13 @@ func Benchmark_Postgres_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Postgres_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Postgres_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/redis/redis_test.go b/redis/redis_test.go index 9ecbb92d..42aca367 100644 --- a/redis/redis_test.go +++ b/redis/redis_test.go @@ -152,11 +152,10 @@ func Test_Redis_Initalize_WithURL_TLS(t *testing.T) { return } tlsCfg := &tls.Config{ - MinVersion: tls.VersionTLS12, - CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, - PreferServerCipherSuites: true, - InsecureSkipVerify: true, - Certificates: []tls.Certificate{cer}, + MinVersion: tls.VersionTLS12, + CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, + InsecureSkipVerify: true, + Certificates: []tls.Certificate{cer}, CipherSuites: []uint16{ tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, @@ -195,11 +194,10 @@ func Test_Redis_Initalize_WithURL_TLS_Verify(t *testing.T) { return } tlsCfg := &tls.Config{ - MinVersion: tls.VersionTLS12, - CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, - PreferServerCipherSuites: true, - InsecureSkipVerify: false, - Certificates: []tls.Certificate{cer}, + MinVersion: tls.VersionTLS12, + CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, + InsecureSkipVerify: false, + Certificates: []tls.Certificate{cer}, CipherSuites: []uint16{ tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, @@ -441,14 +439,13 @@ func Benchmark_Redis_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Redis_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Redis_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/ristretto/ristretto_test.go b/ristretto/ristretto_test.go index c7bf4c5e..f0fcc46c 100644 --- a/ristretto/ristretto_test.go +++ b/ristretto/ristretto_test.go @@ -84,7 +84,7 @@ func Test_Ristretto_Set_Expiration(t *testing.T) { err := testStore.Set(key, val, exp) require.NoError(t, err) - testStore.Reset() + require.NoError(t, testStore.Reset()) } func Test_Ristretto_Get_Expired(t *testing.T) { @@ -190,14 +190,13 @@ func Benchmark_Ristretto_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Ristretto_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Ristretto_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/rueidis/rueidis_test.go b/rueidis/rueidis_test.go index b78cd936..265fb5a7 100644 --- a/rueidis/rueidis_test.go +++ b/rueidis/rueidis_test.go @@ -130,11 +130,10 @@ func Test_Rueidis_WithTLS(t *testing.T) { require.NoError(t, err) } tlsCfg := &tls.Config{ - MinVersion: tls.VersionTLS12, - CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, - PreferServerCipherSuites: true, - InsecureSkipVerify: true, - Certificates: []tls.Certificate{cer}, + MinVersion: tls.VersionTLS12, + CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, + InsecureSkipVerify: true, + Certificates: []tls.Certificate{cer}, CipherSuites: []uint16{ tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, @@ -264,14 +263,13 @@ func Benchmark_Rueidis_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_Rueidis_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_Rueidis_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/s3/s3_test.go b/s3/s3_test.go index e8b0977c..5ed2cc5f 100644 --- a/s3/s3_test.go +++ b/s3/s3_test.go @@ -121,14 +121,13 @@ func Benchmark_S3_Get(b *testing.B) { require.NoError(b, err) } -func Benchmark_S3_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - +func Benchmark_S3_SetAndDelete(b *testing.B) { b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") } diff --git a/sqlite3/sqlite3_test.go b/sqlite3/sqlite3_test.go index 6d790628..c07689be 100644 --- a/sqlite3/sqlite3_test.go +++ b/sqlite3/sqlite3_test.go @@ -183,13 +183,12 @@ func Benchmark_SQLite3_Get(b *testing.B) { } func Benchmark_SQLite3_Delete(b *testing.B) { - err := testStore.Set("john", []byte("doe"), 0) - require.NoError(b, err) - b.ReportAllocs() b.ResetTimer() + var err error for i := 0; i < b.N; i++ { + _ = testStore.Set("john", []byte("doe"), 0) err = testStore.Delete("john") }