1
0
mirror of https://github.com/nxshock/gwp.git synced 2025-04-20 01:21:52 +05:00

Compare commits

..

No commits in common. "main" and "v0.1.9" have entirely different histories.
main ... v0.1.9

3 changed files with 9 additions and 9 deletions

2
go.mod
View File

@ -3,6 +3,6 @@ module github.com/nxshock/gwp
go 1.16
require (
github.com/nxshock/go-eta v0.1.1
github.com/nxshock/go-eta v0.1.0
github.com/stretchr/testify v1.8.0
)

2
go.sum
View File

@ -3,8 +3,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/nxshock/go-eta v0.1.0 h1:rcy8rNPaVeL3f3c5rJRLvho0FErUJThD0+vihxA7t9c=
github.com/nxshock/go-eta v0.1.0/go.mod h1:hZ59FHIJSpPeZk38pd/3zUkI4H31hAQ2oFw+NgdU+SA=
github.com/nxshock/go-eta v0.1.1 h1:N4wi3wjrXJGiheYF4zBIjOwugM+++NWsB1fpeRZaHS4=
github.com/nxshock/go-eta v0.1.1/go.mod h1:hZ59FHIJSpPeZk38pd/3zUkI4H31hAQ2oFw+NgdU+SA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

14
gwp.go
View File

@ -42,7 +42,7 @@ func New(threadCount int) *WorkerPool {
jobChan: make(chan func() error),
resultChan: make(chan error),
stopChan: make(chan struct{}),
eta: eta.New(0)}
eta: eta.New(time.Minute, 0)}
workerPool.wg.Add(threadCount)
@ -123,12 +123,14 @@ func (workerPool *WorkerPool) printProgress() error {
workerPool.errorCount, float64(workerPool.errorCount*100)/float64(workerPool.estimateCount))
}
if workerPool.estimateCount > 0 {
fmt.Fprintf(buf, " ETA: %s", fmtDuration(time.Until(workerPool.eta.Average())))
}
if workerPool.currentSpeed > 0 {
if workerPool.estimateCount > 0 {
fmt.Fprintf(buf, " ETA: %s", fmtDuration(time.Until(workerPool.eta.Average())))
}
if workerPool.currentSpeed > 0 && workerPool.ShowSpeed {
fmt.Fprintf(buf, " Speed: %.2f rps", workerPool.currentSpeed)
if workerPool.ShowSpeed {
fmt.Fprintf(buf, " Speed: %.2f rps", workerPool.currentSpeed)
}
}
fmt.Fprint(buf, endLine)