-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (27 loc) · 906 Bytes
/
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
package main
import (
"calcPiWithThreads/utils"
"fmt"
)
func main() {
var termsQuantity, threadsQnt int
fmt.Print("Digite a quantidade de termos: ")
_, _ = fmt.Scan(&termsQuantity)
fmt.Print("Digite a quantidade de threads: ")
_, _ = fmt.Scan(&threadsQnt)
var numberOfExecutions = 5
statistics := utils.NewStatisticsCalculator()
calculator := utils.NewPiCalculator(termsQuantity, threadsQnt)
for i := 0; i < numberOfExecutions; i++ {
statistics.AddResultSet(
*calculator.Calculate(),
)
}
fmt.Println("Valores - Valores - ( Pi / Tempo de execução ): [")
for _, r := range statistics.GetResultSet() {
fmt.Println(" ", r)
}
fmt.Println("]\nDuração média (ms): ", statistics.GetAverageTimeInMillis())
fmt.Printf("Desvio padrão: %.2f\n", statistics.GetStandardDeviation())
fmt.Printf("Coeficiente de variação: %.4f %%\n", statistics.GetCoefficientOfVariation())
}