Skip to content

Commit

Permalink
Move some types so they are available outside the package
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanslade committed Nov 13, 2024
1 parent 6107a37 commit fa0ecfd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
40 changes: 40 additions & 0 deletions internal/benchmarks/benchmarks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package benchmarks

import (
"os"
"sync"
"time"
)

type ReportRecorder struct {
mu sync.Mutex
GitSHA string
PostgresVersion string
Timestamp int64
Reports []Report
}

func (r *ReportRecorder) AddReport(report Report) {
r.mu.Lock()
defer r.mu.Unlock()
r.Reports = append(r.Reports, report)
}

func getPostgresVersion() string {
return os.Getenv("POSTGRES_VERSION")
}

func newReportRecorder() *ReportRecorder {
return &ReportRecorder{
GitSHA: os.Getenv("GITHUB_SHA"),
PostgresVersion: getPostgresVersion(),
Timestamp: time.Now().Unix(),
Reports: []Report{},
}
}

type Report struct {
Name string
RowCount int
RowsPerSecond float64
}
35 changes: 0 additions & 35 deletions internal/benchmarks/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
"fmt"
"os"
"strconv"
"sync"
"testing"
"time"

"github.com/lib/pq"
"github.com/oapi-codegen/nullable"
Expand Down Expand Up @@ -234,36 +232,3 @@ var migAlterColumn = migrations.Migration{
}

func ptr[T any](x T) *T { return &x }

type ReportRecorder struct {
mu sync.Mutex
GitSHA string
PostgresVersion string
Timestamp int64
Reports []Report
}

func getPostgresVersion() string {
return os.Getenv("POSTGRES_VERSION")
}

func newReportRecorder() *ReportRecorder {
return &ReportRecorder{
GitSHA: os.Getenv("GITHUB_SHA"),
PostgresVersion: getPostgresVersion(),
Timestamp: time.Now().Unix(),
Reports: []Report{},
}
}

func (r *ReportRecorder) AddReport(report Report) {
r.mu.Lock()
defer r.mu.Unlock()
r.Reports = append(r.Reports, report)
}

type Report struct {
Name string
RowCount int
RowsPerSecond float64
}

0 comments on commit fa0ecfd

Please sign in to comment.