Biometric time remaining accounting for skipped files.
This commit is contained in:
@@ -26,6 +26,7 @@ const humanConfig = {
|
||||
|
||||
let humanInstance = null;
|
||||
const nsPerSec = 1e9;
|
||||
const remainingTimeWindow = 30; // number of recent entries used to estimate time remaining
|
||||
|
||||
async function getHumanInstance() {
|
||||
if (!humanInstance) {
|
||||
@@ -118,6 +119,7 @@ async function setBiometrics(actorIds, shouldUpdate = false, includePhotos = fal
|
||||
}
|
||||
|
||||
const startTime = process.hrtime();
|
||||
const recentDurationsMs = [];
|
||||
|
||||
const avatarSource = getAvatarSource(actorIds, includePhotos);
|
||||
|
||||
@@ -142,6 +144,8 @@ async function setBiometrics(actorIds, shouldUpdate = false, includePhotos = fal
|
||||
return;
|
||||
}
|
||||
|
||||
const entryStartTime = process.hrtime();
|
||||
|
||||
const biometrics = await getBiometrics(avatarEntry);
|
||||
|
||||
if (!biometrics) {
|
||||
@@ -184,14 +188,20 @@ async function setBiometrics(actorIds, shouldUpdate = false, includePhotos = fal
|
||||
.onConflict(['media_id', 'face_index'])
|
||||
.ignore();
|
||||
|
||||
const processed = avatarIndex + 1;
|
||||
const [elapsedSec, elapsedNs] = process.hrtime(startTime);
|
||||
const elapsedMs = (elapsedSec * nsPerSec + elapsedNs) / 1e6;
|
||||
const avgMsPerEntry = elapsedMs / processed;
|
||||
const remainingMs = avgMsPerEntry * (avatarEntries.length - processed);
|
||||
const [entrySec, entryNs] = process.hrtime(entryStartTime);
|
||||
const entryMs = (entrySec * nsPerSec + entryNs) / 1e6;
|
||||
|
||||
recentDurationsMs.push(entryMs);
|
||||
|
||||
if (recentDurationsMs.length > remainingTimeWindow) {
|
||||
recentDurationsMs.shift();
|
||||
}
|
||||
|
||||
const avgMsPerEntry = recentDurationsMs.reduce((sum, ms) => sum + ms, 0) / recentDurationsMs.length;
|
||||
const remainingMs = avgMsPerEntry * (avatarEntries.length - (avatarIndex + 1));
|
||||
const remainingMinutes = (remainingMs / 1000 / 60).toFixed(1);
|
||||
|
||||
logger.info(`Set biometrics for ${avatarEntry.media_id} (${processed}/${avatarEntries.length}, ~${remainingMinutes}m remaining)`);
|
||||
logger.info(`Set biometrics for ${avatarEntry.media_id} (${avatarIndex + 1}/${avatarEntries.length}, ~${remainingMinutes}m remaining)`);
|
||||
}, Promise.resolve());
|
||||
|
||||
const diffTime = process.hrtime(startTime);
|
||||
|
||||
Reference in New Issue
Block a user