jquery-ui/tests/runner/lib/prettyMs.js
Timmy Willison 91df20be6b
Tests: replace grunt-contrib-qunit with jQuery test runner
- add filestash workflow

Close gh-2221
2024-03-29 09:13:46 -04:00

19 lines
412 B
JavaScript

/**
* Pretty print a time in milliseconds.
*/
export function prettyMs( time ) {
const minutes = Math.floor( time / 60000 );
const seconds = Math.floor( time / 1000 );
const ms = Math.floor( time % 1000 );
let prettyTime = `${ ms }ms`;
if ( seconds > 0 ) {
prettyTime = `${ seconds }s ${ prettyTime }`;
}
if ( minutes > 0 ) {
prettyTime = `${ minutes }m ${ prettyTime }`;
}
return prettyTime;
}