MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / parseTimeMS

Function parseTimeMS

framework/utils/lib/common.ts:154–160  ·  view source on GitHub ↗
(str: string | number, throwOnError = true)

Source from the content-addressed store, hash-verified

152const MEMORY_UNITS = { k: 1 / 1024, m: 1, g: 1024 } as Record<string, number>;
153
154export function parseTimeMS(str: string | number, throwOnError = true) {
155 if (typeof str === 'number' || Number.isSafeInteger(+str)) return +str;
156 const match = TIME_RE.exec(str);
157 if (!match && throwOnError) throw new Error(`${str} error parsing time`);
158 if (!match) return 1000;
159 return Math.floor(Number.parseFloat(match[1]) * TIME_UNITS[match[2].toLowerCase()]);
160}
161
162export function parseMemoryMB(str: string | number, throwOnError = true) {
163 if (typeof str === 'number' || Number.isSafeInteger(+str)) return +str;

Callers 14

reducerFunction · 0.90
SubtaskSettingsFunction · 0.90
GlobalSettingsFunction · 0.90
parseConfigFunction · 0.90
runGeneratorFunction · 0.90
runStdFunction · 0.90
judgeCaseFunction · 0.90
judgeFunction · 0.90
readYamlCasesFunction · 0.90
normalizeSubtasksFunction · 0.90
generateCdpZipFunction · 0.85
waitForSubmissionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected