Skip to content

Commit

Permalink
add exclude-substrings flag (#16)
Browse files Browse the repository at this point in the history
Previous version of performance CLI was working with file extensions, however now it should be run inside the Jenkins environment, at the same time Jenkinsfile will be generated from SDK that does not have such metadata as extension. Thus extensions flag was changed to exclude-substrings. Default values are set with the respect to a fixtures suite of every driver, excluding files with AST contents.

Signed-off-by: lwsanty <[email protected]>
  • Loading branch information
lwsanty authored Jul 23, 2019
1 parent eb3694b commit 60e42fa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ Full examples of usage scripts are following:
# for prometheus pushgateway
export PROM_ADDRESS="localhost:9091"
export PROM_JOB=pushgateway
./bblfsh-performance end-to-end --language=go --commit=3d9682b --extension=".go" --storage="prom" /var/testdata/benchmarks
./bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --exclude-suffixes=".legacy",".native",".uast" --storage="prom" /var/testdata/benchmarks
# for influx db
export INFLUX_ADDRESS="http://localhost:8086"
export INFLUX_USERNAME=""
export INFLUX_PASSWORD=""
export INFLUX_DB=mydb
export INFLUX_MEASUREMENT=benchmark
bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --extension=".go" --storage="influxdb" /var/testdata/benchmarks
bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --exclude-suffixes=".legacy",".native",".uast" --storage="influxdb" /var/testdata/benchmarks
Flags:
-c, --commit string commit id that's being tested and will be used as a tag in performance report
--custom-driver if this flag is set to true CLI pulls corresponding language driver repo's commit, builds docker image and installs it onto the bblfsh container
-t, --docker-tag string bblfshd docker image tag to be tested (default "latest-drivers")
-e, --extension string file extension to be filtered
--filter-prefix string file prefix to be filtered (default "bench_")
-h, --help help for end-to-end
-l, --language string name of the language to be tested
-s, --storage string storage kind to store the results(prom, influxdb, file) (default "prom")
-c, --commit string commit id that's being tested and will be used as a tag in performance report
--custom-driver if this flag is set to true CLI pulls corresponding language driver repo's commit, builds docker image and installs it onto the bblfsh container
-t, --docker-tag string bblfshd docker image tag to be tested (default "latest-drivers")
--exclude-suffixes strings file suffixes to be excluded (default [.legacy,.native,.uast])
--filter-prefix string file prefix to be filtered (default "bench_")
-h, --help help for end-to-end
-l, --language string name of the language to be tested
-s, --storage string storage kind to store the results(prom, influxdb, file) (default "prom")
```
10 changes: 5 additions & 5 deletions cmd/bblfsh-performance/endtoend/endtoend.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ Full examples of usage scripts are following:
# for prometheus pushgateway
export PROM_ADDRESS="localhost:9091"
export PROM_JOB=pushgateway
./bblfsh-performance end-to-end --language=go --commit=3d9682b --extension=".go" --storage="prom" /var/testdata/benchmarks
./bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --exclude-suffixes=".legacy",".native",".uast" --storage="prom" /var/testdata/benchmarks
# for influx db
export INFLUX_ADDRESS="http://localhost:8086"
export INFLUX_USERNAME=""
export INFLUX_PASSWORD=""
export INFLUX_DB=mydb
export INFLUX_MEASUREMENT=benchmark
bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --extension=".go" --storage="influxdb" /var/testdata/benchmarks`,
bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="bench_" --exclude-suffixes=".legacy",".native",".uast" --storage="influxdb" /var/testdata/benchmarks`,
RunE: performance.RunESilenced(func(cmd *cobra.Command, args []string) error {
language, _ := cmd.Flags().GetString("language")
commit, _ := cmd.Flags().GetString("commit")
extension, _ := cmd.Flags().GetString("extension")
excludeSubstrings, _ := cmd.Flags().GetStringSlice("exclude-suffixes")
stor, _ := cmd.Flags().GetString("storage")
filterPrefix, _ := cmd.Flags().GetString("filter-prefix")
customDriver, _ := cmd.Flags().GetBool("custom-driver")
Expand Down Expand Up @@ -121,7 +121,7 @@ bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="be
}
defer client.Close()

files, err := performance.GetFiles(filterPrefix, extension, args...)
files, err := performance.GetFiles(filterPrefix, excludeSubstrings, args...)
if err != nil {
return errGetFiles.Wrap(err)
} else if len(files) == 0 {
Expand Down Expand Up @@ -168,7 +168,7 @@ bblfsh-performance end-to-end --language=go --commit=3d9682b --filter-prefix="be
flags := cmd.Flags()
flags.StringP("language", "l", "", "name of the language to be tested")
flags.StringP("commit", "c", "", "commit id that's being tested and will be used as a tag in performance report")
flags.StringP("extension", "e", "", "file extension to be filtered")
flags.StringSlice("exclude-suffixes", []string{".legacy", ".native", ".uast"}, "file suffixes to be excluded")
flags.StringP("docker-tag", "t", bblfshDefaultConfTag, "bblfshd docker image tag to be tested")
flags.String("filter-prefix", fileFilterPrefix, "file prefix to be filtered")
flags.StringP("storage", "s", prom_pushgateway.Kind, "storage kind to store the results"+
Expand Down
21 changes: 18 additions & 3 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,31 @@ func RunESilenced(f RunE) RunE {
}
}

func stringInSlice(s string, strSlice []string) bool {
for _, sl := range strSlice {
if strings.HasSuffix(s, sl) {
return true
}
}
return false
}

// GetFiles is a simple "get files by pattern" function
// Purpose: filter required fixtures
func GetFiles(pref, ext string, dirs ...string) ([]string, error) {
func GetFiles(pref string, exclusionSuffixes []string, dirs ...string) ([]string, error) {
var res []string
for _, d := range dirs {
matches, err := filepath.Glob(filepath.Join(d, pref+"*"+ext))
matches, err := filepath.Glob(filepath.Join(d, pref+"*"))
if err != nil {
return nil, err
}
res = append(res, matches...)

for _, m := range matches {
if stringInSlice(m, exclusionSuffixes) {
continue
}
res = append(res, m)
}
}
return res, nil
}
Expand Down

0 comments on commit 60e42fa

Please sign in to comment.