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)
|
timer_elapsed := time.Since(timer_start)
|
||||||
rate := int64(rate_diff) / int64(timer_elapsed.Seconds())
|
solver.rates = append(solver.rates, rate_diff)
|
||||||
solver.rates = append(solver.rates, rate)
|
|
||||||
rate_avg := solver.calc_avg()
|
rate_avg := solver.calc_avg()
|
||||||
|
|
||||||
// Estimate when this is finished
|
// Estimate when this is finished
|
||||||
if rate_diff == 0 {
|
if rate_diff == 0 {
|
||||||
est_fin = "N/A"
|
est_fin = "N/A"
|
||||||
} else {
|
} 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
|
// 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
|
// After we are done printing, exit this for-loop
|
||||||
if percentage == 100 {
|
if percentage == 100 {
|
||||||
@ -170,6 +169,7 @@ func (solver *Solver) tracker() {
|
|||||||
|
|
||||||
// Resert the rate counter
|
// Resert the rate counter
|
||||||
rate_start = solver.counter
|
rate_start = solver.counter
|
||||||
|
|
||||||
// Sleep for a second
|
// Sleep for a second
|
||||||
time.Sleep(1 * time.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
|
return retval
|
||||||
}
|
}
|
||||||
|
|
||||||
func (solver *Solver) calc_avg() int {
|
func (solver *Solver) calc_avg() (avg int64) {
|
||||||
var avg_sum int64
|
var avg_sum int64
|
||||||
var avg int
|
|
||||||
|
|
||||||
for _, value := range solver.rates {
|
for _, value := range solver.rates {
|
||||||
avg_sum += value
|
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
|
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)
|
years := math.Floor(float64(input) / 60 / 60 / 24 / 7 / 30 / 12)
|
||||||
seconds := 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)
|
months := math.Floor(float64(seconds) / 60 / 60 / 24 / 7 / 30)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user