aboutsummaryrefslogtreecommitdiff
path: root/benchmark/benchmark_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-04-19 14:25:13 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-04-19 14:25:13 +0200
commite4c744843e740e74b824c43950b1961736ccb8ad (patch)
tree83ee79a50bf788a5e9f7f62ddf6a9ce62514936b /benchmark/benchmark_test.go
parent6a089f6d65da3ef5391314e1ab5907083bf577fc (diff)
downloadgo-oblast-e4c744843e740e74b824c43950b1961736ccb8ad.tar.gz
change Store.Insert() to take arguments by pointer
This increases memory overhead slightly, but when converting Gorp uses into Oblast, I saw that there is a legitimate risk of just ignoring the result value and continuing with the unupdated records. So according to the design priorities that I myself laid down, I'm sacrificing some performance for safety of use.
Diffstat (limited to 'benchmark/benchmark_test.go')
-rw-r--r--benchmark/benchmark_test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go
index ada238e..d18c0cb 100644
--- a/benchmark/benchmark_test.go
+++ b/benchmark/benchmark_test.go
@@ -268,10 +268,12 @@ func BenchmarkInsertAndDelete(b *testing.B) {
// prepare the functions that will be benched
insertAndDeleteWithOblast := func(b *testing.B) {
records := make([]OblastEntry, batchSize)
+ recordsForInsert := make([]*OblastEntry, batchSize)
for idx := range records {
records[idx] = OblastEntry{Message: "hello"}
+ recordsForInsert[idx] = &records[idx]
}
- records = must.Return(store.Insert(db, records...))(b)
+ must.Succeed(b, store.Insert(db, recordsForInsert...))
for _, r := range records {
if r.ID == 0 {
b.Errorf("ID was not filled!")
@@ -388,10 +390,12 @@ func BenchmarkUpdate(b *testing.B) {
// prepare a bunch of records that we can update, in a reproducible way
_ = must.Return(db.Exec(`DELETE FROM entries`))
recordsForOblast := make([]OblastEntry, batchSize)
+ recordsForOblastForInsert := make([]*OblastEntry, batchSize)
for idx := range recordsForOblast {
recordsForOblast[idx] = OblastEntry{Message: "hello"}
+ recordsForOblastForInsert[idx] = &recordsForOblast[idx]
}
- recordsForOblast = must.Return(store.Insert(db, recordsForOblast...))(b)
+ must.Succeed(b, store.Insert(db, recordsForOblastForInsert...))
recordsForGorp := make([]any, batchSize)
for idx, r := range recordsForOblast {
recordsForGorp[idx] = new(GorpEntry(r))