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