diff options
author | Franck Cuny <franck@fcuny.net> | 2022-10-15 12:32:28 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-10-15 12:32:28 -0700 |
commit | ce39b5fd65a91e241b2edbb9fd6a9a12967a064d (patch) | |
tree | bd0ec3519ac3a41c55193023dc3f3bb2705114a1 /tools/seqstat/seqstat.go | |
parent | ci: update the flake once a week (diff) | |
download | world-ce39b5fd65a91e241b2edbb9fd6a9a12967a064d.tar.gz |
ref(seqstat): rewrite from go to python
This is a simple script, there's no benefit in having this in go. Having it Python makes it easier to extend with panda or other libraries in the future if I need more statistics too.
Diffstat (limited to '')
-rw-r--r-- | tools/seqstat/seqstat.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/tools/seqstat/seqstat.go b/tools/seqstat/seqstat.go deleted file mode 100644 index 8709fa4..0000000 --- a/tools/seqstat/seqstat.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "bufio" - "flag" - "fmt" - "os" - "strconv" - "strings" -) - -var ( - stats = flag.Bool("S", false, "Display statistics about the sequence.") -) - -func main() { - flag.Parse() - - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "usage: [-S] <INPUT>") - flag.PrintDefaults() - } - - elements := argsToElements(flag.Args()) - - if len(elements) < 1 { - scanner := bufio.NewScanner(os.Stdin) - var e []string - for scanner.Scan() { - e = append(e, strings.Split(scanner.Text(), " ")...) - } - elements = argsToElements(e) - } - - seq := newSequence(elements) - - fmt.Println(string(seq.histogram())) - - if *stats { - fmt.Printf("min: %f\n", seq.min) - fmt.Printf("max: %f\n", seq.max) - fmt.Printf("avg: %f\n", seq.avg()) - fmt.Printf("p50: %f\n", seq.p50()) - fmt.Printf("p90: %f\n", seq.p90()) - fmt.Printf("p99: %f\n", seq.p99()) - fmt.Printf("p999: %f\n", seq.p999()) - fmt.Printf("ordered sequence: %v\n", seq.elementsSorted) - } -} - -// converts the input to float64 -func argsToElements(args []string) []float64 { - elements := make([]float64, len(args)) - - for i, input := range args { - num, err := strconv.ParseFloat(input, 64) - if err != nil { - panic(err) - } - elements[i] = num - } - return elements -} |