Skip to content

Commit

Permalink
Add FK comparison route to the API
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Jan 15, 2024
1 parent 49330b2 commit 80c30af
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
19 changes: 18 additions & 1 deletion go/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ func (s *Server) requestRun(c *gin.Context) {
}
currVersion := git.Version{Major: version}


configs := s.getConfigFiles()
cfg, ok := configs[strings.ToLower(benchmarkType)]
if !ok {
Expand Down Expand Up @@ -451,3 +450,21 @@ func (s *Server) deleteRun(c *gin.Context) {
c.JSON(http.StatusOK, "deleted")
}

func (s *Server) compareBenchmarkFKs(c *gin.Context) {
sha := c.Query("sha")

var mtypes []string
for _, benchmarkType := range s.benchmarkTypes {
if strings.Contains(benchmarkType, "TPCC") {
mtypes = append(mtypes, benchmarkType)
}
}

allBenchmarkResults, err := macrobench.GetDetailsFromAllTypes(sha, macrobench.Gen4Planner, s.dbClient, mtypes)
if err != nil {
c.JSON(http.StatusInternalServerError, &ErrorAPI{Error: err.Error()})
slog.Error(err)
return
}
c.JSON(http.StatusOK, allBenchmarkResults)
}
11 changes: 6 additions & 5 deletions go/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ func (s *Server) Run() error {
return errors.New(ErrorIncorrectConfiguration)
}

err := s.createCrons()
if err != nil {
return err
}
// err := s.createCrons()
// if err != nil {
// return err
// }

err = s.ghApp.Init()
err := s.ghApp.Init()
if err != nil {
return err
}
Expand All @@ -232,6 +232,7 @@ func (s *Server) Run() error {
s.router.GET("/api/recent", s.getRecentExecutions)
s.router.GET("/api/queue", s.getExecutionsQueue)
s.router.GET("/api/vitess/refs", s.getLatestVitessGitRef)
s.router.GET("/api/fk/compare", s.compareBenchmarkFKs)
s.router.GET("/api/macrobench/compare", s.compareMacrobenchmarks)
s.router.GET("/api/microbench/compare", s.compareMicrobenchmarks)
s.router.GET("/api/search", s.searchBenchmarck)
Expand Down
16 changes: 16 additions & 0 deletions go/tools/macrobench/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,22 @@ func (qps QPS) OtherStr() string {
return humanize.FormatFloat("#,###.#", qps.Other)
}

func GetDetailsFromAllTypes(sha string, planner PlannerVersion, dbclient storage.SQLClient, types []string) (map[string]Details, error) {
details, err := GetDetailsArraysFromAllTypes(sha, planner, dbclient, types)
if err != nil {
return nil, err
}
result := make(map[string]Details, len(details))
for s, array := range details {
var d Details
if len(array) == 1 {
d = array[0]
}
result[s] = d
}
return result, nil
}

// GetDetailsArraysFromAllTypes returns a slice of Details based on the given git ref and Types.
func GetDetailsArraysFromAllTypes(sha string, planner PlannerVersion, dbclient storage.SQLClient, types []string) (map[string]DetailsArray, error) {
macros := map[string]DetailsArray{}
Expand Down

0 comments on commit 80c30af

Please sign in to comment.