diff options
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | benchmark/benchmark_test.go | 4 | ||||
| -rw-r--r-- | query.go | 3 |
3 files changed, 10 insertions, 4 deletions
@@ -6,3 +6,10 @@ SPDX-License-Identifier: Apache-2.0 # Oblast My attempt at an ORM library for Go. Inspired by [Gorp](https://pkg.go.dev/gopkg.in/gorp.v3), but without the bits that make Gorp slow. + +## Unstructured notes + +TODO: write out a proper readme + +- goals: as fast as possible, as little allocs on hot paths as possible +- consequences: no `context.Context` (benchmarking shows up to 50% more allocations and 100% more memory allocated in OLTP usecase, i.e. QueryRow vs. QueryRowContext) diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go index c08361e..9c0c326 100644 --- a/benchmark/benchmark_test.go +++ b/benchmark/benchmark_test.go @@ -54,10 +54,10 @@ func BenchmarkSelect(b *testing.B) { ID int `db:"id"` Message string `db:"message"` } - query := `SELECT * FROM entries WHERE id < ` + strconv.Itoa(selectedRecordCount) + query := `SELECT * FROM entries WHERE id < ` + strconv.Itoa(selectedRecordCount) //nolint:gosec selectWithOblast := func(b *testing.B) { - records, err := oblast.Select[record](b.Context(), odb, query) + records, err := oblast.Select[record](odb, query) if err != nil { b.Error(err) } @@ -4,12 +4,11 @@ package oblast import ( - "context" "fmt" "reflect" ) -func Select[T any](ctx context.Context, db *DB, query string, args ...any) ([]T, error) { +func Select[T any](db *DB, query string, args ...any) ([]T, error) { // TODO: minimize function body to avoid binary size blowup from monomorphization // TODO: catch error from rows.Close(), if any // TODO: add context to errors |
