mirror of
https://github.com/ow-mods/ow-mod-db.git
synced 2025-12-11 20:15:24 +01:00
measure time to run each thing
This commit is contained in:
parent
2f30a0aeb1
commit
3d833d715b
@ -12,7 +12,7 @@ export async function getInstallCounts(
|
||||
).toString();
|
||||
|
||||
const analyticsDataClient = new BetaAnalyticsDataClient({
|
||||
credentials: JSON.parse(googleServiceAccountCredentials),
|
||||
credentials: JSON.parse(base64GoogleServiceAccountCredentials),
|
||||
projectId: "outer-wilds-mods",
|
||||
});
|
||||
|
||||
|
||||
@ -37,10 +37,16 @@ export const getModPathName = (modName: string) =>
|
||||
modName.replace(/\W/g, "").toLowerCase();
|
||||
|
||||
const getSettledResult = <TResult>(
|
||||
results: PromiseSettledResult<TResult>
|
||||
results: PromiseSettledResult<TResult>,
|
||||
name: string,
|
||||
initialTime: number
|
||||
): TResult | undefined => {
|
||||
if (results.status == "rejected") return undefined;
|
||||
|
||||
console.log(
|
||||
`Finished getting ${name} in ${performance.now() - initialTime} ms`
|
||||
);
|
||||
|
||||
return results.value;
|
||||
};
|
||||
|
||||
@ -53,6 +59,8 @@ async function getAsyncStuff() {
|
||||
getPreviousDatabase(),
|
||||
] as const;
|
||||
|
||||
const initialTime = performance.now();
|
||||
|
||||
const [
|
||||
modManager,
|
||||
nextDatabase,
|
||||
@ -62,11 +70,14 @@ async function getAsyncStuff() {
|
||||
] = await Promise.allSettled(promises);
|
||||
|
||||
return {
|
||||
modManager: getSettledResult(modManager),
|
||||
nextDatabase: getSettledResult(nextDatabase) ?? [],
|
||||
viewCounts: getSettledResult(viewCounts) ?? {},
|
||||
installCounts: getSettledResult(installCounts) ?? {},
|
||||
previousDatabase: getSettledResult(previousDatabase) ?? [],
|
||||
modManager: getSettledResult(modManager, "modManager", initialTime),
|
||||
nextDatabase:
|
||||
getSettledResult(nextDatabase, "nextDatabase", initialTime) ?? [],
|
||||
viewCounts: getSettledResult(viewCounts, "viewCounts", initialTime) ?? {},
|
||||
installCounts:
|
||||
getSettledResult(installCounts, "installCounts", initialTime) ?? {},
|
||||
previousDatabase:
|
||||
getSettledResult(previousDatabase, "previousDatabase", initialTime) ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user