Skip to content

Commit

Permalink
Include bin info (commit hash and if changed) on tool (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecosta90 committed Mar 31, 2023
1 parent c493fe4 commit 2e640a2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ fmt:
$(GOFMT) ./...

ftsb_redisearch: test
$(GOBUILD) -o bin/$@ ./cmd/$@
$(GOBUILD) \
-ldflags=$(LDFLAGS) \
-o bin/$@ ./cmd/$@

get:
$(GOGET) ./...
Expand Down
26 changes: 26 additions & 0 deletions cmd/ftsb_redisearch/bin_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"strconv"
"strings"
)

// Vars only for git sha and diff handling
var GitSHA1 string = ""
var GitDirty string = "0"

// internal function to return value of GitSHA1 var, which is filled in link time
func toolGitSHA1() string {
return GitSHA1
}

// this internal function will check for the number of altered lines that are not yet committed
// and return true in that case
func toolGitDirty() (dirty bool) {
dirty = false
dirtyLines, err := strconv.Atoi(strings.TrimSpace(GitDirty))
if err == nil {
dirty = (dirtyLines != 0)
}
return
}
7 changes: 7 additions & 0 deletions cmd/ftsb_redisearch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"flag"
"github.com/RediSearch/ftsb/benchmark_runner"
"log"
)

// Program option vars:
Expand Down Expand Up @@ -71,5 +72,11 @@ func (b *benchmark) GetProcessor() benchmark_runner.Processor {

func main() {
b := benchmark{}
git_sha := toolGitSHA1()
git_dirty_str := ""
if toolGitDirty() {
git_dirty_str = "-dirty"
}
log.Printf("ftsb (git_sha1:%s%s)\n", git_sha, git_dirty_str)
loader.RunBenchmark(&b, benchmark_runner.SingleQueue)
}

0 comments on commit 2e640a2

Please sign in to comment.