-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
46 lines (42 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"strings"
)
func main() {
runs := flag.Uint64("runs", 500, "Count of runs per execution to calculate average. Default: 1500")
time := flag.Bool("execution-time", false, "calculate average execution time")
sol := flag.String("sol", "", "Solidity file to benchmark")
sol_dir := flag.String("sol-dir", "", "Directory of benchmark smart contracts")
flag.Parse()
if *sol != "" && *sol_dir != "" {
fmt.Println("--sol and --sol-dir cannot be set at the same time.")
}
if *sol == "" && *sol_dir == "" {
fmt.Println("No Solidity files to benchmark specified, please set --sol(single source) or --sol-dir (iterate over directory).")
}
if *sol != "" {
err := bsol(*runs, *time, *sol)
if err != nil {
fmt.Print(err.Error())
}
}
_ = time
if *sol_dir != "" {
var src []string
err := filepath.Walk(*sol_dir, func(path string, info os.FileInfo, err error) error {
if !strings.Contains(path, ".sol") {
return nil
}
src = append(src, path)
return nil
})
err = bsol(*runs, *time, src...)
if err != nil {
fmt.Print(err.Error())
}
}
}