Fixing a leftover of #6, refactored to int64.
This commit is contained in:
parent
acf6ad1bb9
commit
53953cf47c
@ -138,19 +138,18 @@ func (solver *Solver) tracker() {
|
||||
}
|
||||
|
||||
timer_elapsed := time.Since(timer_start)
|
||||
rate := int64(rate_diff) / int64(timer_elapsed.Seconds())
|
||||
solver.rates = append(solver.rates, rate)
|
||||
solver.rates = append(solver.rates, rate_diff)
|
||||
rate_avg := solver.calc_avg()
|
||||
|
||||
// Estimate when this is finished
|
||||
if rate_diff == 0 {
|
||||
est_fin = "N/A"
|
||||
} else {
|
||||
est_fin = solver.secondsToHuman((int(solver.iter) - int(solver.counter)) / int(rate_avg))
|
||||
est_fin = solver.secondsToHuman((solver.iter - solver.counter) / rate_avg)
|
||||
}
|
||||
|
||||
// Printing the progress
|
||||
log.Println("Processing: " + strconv.Itoa(int(percentage)) + "% (" + strconv.Itoa(int(solver.counter)) + "/" + strconv.Itoa(int(solver.iter)) + "); Rate: " + strconv.Itoa(int(rate)) + "/sec for " + timer_elapsed.String() + "; Time left (est.): " + est_fin)
|
||||
log.Println("Processing: " + strconv.Itoa(int(percentage)) + "% (" + strconv.Itoa(int(solver.counter)) + "/" + strconv.Itoa(int(solver.iter)) + "); Rate: " + strconv.FormatInt(rate_diff, 10) + "/sec for " + timer_elapsed.String() + "; Time left (est.): " + est_fin)
|
||||
|
||||
// After we are done printing, exit this for-loop
|
||||
if percentage == 100 {
|
||||
@ -170,6 +169,7 @@ func (solver *Solver) tracker() {
|
||||
|
||||
// Resert the rate counter
|
||||
rate_start = solver.counter
|
||||
|
||||
// Sleep for a second
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
@ -233,15 +233,14 @@ func (solver *Solver) validate_combination(row1 int, row2 int, row3 int, row4 in
|
||||
return retval
|
||||
}
|
||||
|
||||
func (solver *Solver) calc_avg() int {
|
||||
func (solver *Solver) calc_avg() (avg int64) {
|
||||
var avg_sum int64
|
||||
var avg int
|
||||
|
||||
for _, value := range solver.rates {
|
||||
avg_sum += value
|
||||
}
|
||||
|
||||
avg = int(avg_sum) / len(solver.rates)
|
||||
avg = avg_sum / int64(len(solver.rates))
|
||||
|
||||
return avg
|
||||
return
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func (solver *Solver) plural(count int, singular string) (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
func (solver *Solver) secondsToHuman(input int) (result string) {
|
||||
func (solver *Solver) secondsToHuman(input int64) (result string) {
|
||||
years := math.Floor(float64(input) / 60 / 60 / 24 / 7 / 30 / 12)
|
||||
seconds := input % (60 * 60 * 24 * 7 * 30 * 12)
|
||||
months := math.Floor(float64(seconds) / 60 / 60 / 24 / 7 / 30)
|
||||
|
Loading…
x
Reference in New Issue
Block a user