forked from MapComplete/MapComplete
Scripts(offline): add eta
This commit is contained in:
parent
2656d1e650
commit
d2500d6db2
1 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,7 @@ import { OfflineBasemapManager } from "../src/service-worker/OfflineBasemapManag
|
|||
|
||||
import { spawn } from "child_process"
|
||||
import { existsSync } from "fs"
|
||||
import { Utils } from "../src/Utils"
|
||||
|
||||
|
||||
class GeneratePmTilesExtracts extends Script {
|
||||
|
@ -99,12 +100,17 @@ class GeneratePmTilesExtracts extends Script {
|
|||
const generator = this.generateAll()
|
||||
let batch: Promise<void>[] = []
|
||||
let done = 0
|
||||
const startDate = new Date()
|
||||
do {
|
||||
batch = this.createBatch(generator, numberOfThreads)
|
||||
await Promise.all(batch)
|
||||
done += batch.length
|
||||
const now = new Date()
|
||||
const timeElapsed = (now.getTime() - startDate.getTime()) / 1000
|
||||
const speed = ("" + (done / timeElapsed)).substring(0, 5)
|
||||
const perc = ("" + ((100 * (done + this.skipped) / estimate))).substring(0, 5)
|
||||
console.log("Completed", numberOfThreads, `processes; ${done + this.skipped} / ${estimate}, ${perc}%`)
|
||||
const etaSecond = Math.floor((estimate - done - this.skipped) * timeElapsed / done)
|
||||
console.log("Completed", numberOfThreads, `processes; ${done + this.skipped} / ${estimate}, ${perc}%, ${speed} tile/second, ETA: ${Utils.toHumanTime(etaSecond)}`)
|
||||
} while (batch.length > 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue