diff options
| author | Rob Findley <rfindley@google.com> | 2019-09-24 15:20:57 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-03-27 16:46:43 -0400 |
| commit | b0cdd8a50f07b31b535cc2a4d72668c3a6b929bf (patch) | |
| tree | e175d32f7f0535e33d68b580c9c043d5760a149c /internal/postgres/postgres.go | |
| parent | 966b71c013cfd584ba7d7313bc7865b619c13580 (diff) | |
| download | go-x-pkgsite-b0cdd8a50f07b31b535cc2a4d72668c3a6b929bf.tar.xz | |
internal/postgres: add a search benchmark
A search benchmark is added, to be run against a dev instance of the
database.
Updates b/141182438
Change-Id: I73e9742cc6697f282a84252ab85b85d7dc0c689f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/556705
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres/postgres.go')
| -rw-r--r-- | internal/postgres/postgres.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/postgres/postgres.go b/internal/postgres/postgres.go index 32d9a35a..220a2b5f 100644 --- a/internal/postgres/postgres.go +++ b/internal/postgres/postgres.go @@ -45,9 +45,15 @@ func (db *DB) queryRow(ctx context.Context, query string, args ...interface{}) * return db.db.QueryRowContext(ctx, query, args...) } -var queryCounter int64 // atomic: per-process counter for unique query IDs +var ( + queryCounter int64 // atomic: per-process counter for unique query IDs + queryLoggingDisabled bool // For use in benchmarks only: not concurrency-safe. +) func logQuery(query string, args []interface{}) func(*error) { + if queryLoggingDisabled { + return func(*error) {} + } const maxlen = 300 // maximum length of displayed query // To make the query more compact and readable, replace newlines with spaces |
