Skip to content

Commit

Permalink
fixed time duration formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jun 29, 2024
1 parent 8fdef04 commit 36ec190
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- 2.8.6
- improved performance
- fixed warning message for adding empty istanbul coverage
- fixed time duration formatter

- 2.8.5
- fixed a sourcemap content issue
Expand Down
11 changes: 8 additions & 3 deletions lib/converter/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,8 @@ const convertV8List = (v8list, options) => {
for (const item of v8list) {
// console.log([item.id]);

const time_start_ast = Date.now();

const {
type, source, fake, sourcePath
} = item;
Expand All @@ -1513,7 +1515,6 @@ const convertV8List = (v8list, options) => {
}

// ============================
const time_start_ast = Date.now();
// move functions and ranges to coverageList
let coverageList = [];
let astInfo;
Expand All @@ -1532,11 +1533,14 @@ const convertV8List = (v8list, options) => {
delete item.ranges;
}
}

Util.logTime(` ┌ [convert] parsed ast: ${sourcePath} (${EC.cyan(Util.BSF(maxContentLength))})`, time_start_ast);

// console.log(sourcePath, astInfo.statements.length);
// ============================

const time_start_unpack = Date.now();

// current file and it's sources from sourceMap
// see const originalState
const state = {
Expand Down Expand Up @@ -1567,16 +1571,17 @@ const convertV8List = (v8list, options) => {
v8Data: item
};

const time_start_unpack = Date.now();
unpackDistFile(item, state, options);
const unpackedFiles = EC.cyan(`${state.originalList.length} files`);
Util.logTime(` ┌ [convert] unpacked sourcemap: ${sourcePath} (${unpackedFiles})`, time_start_unpack);

stateList.push(state);

Util.logTime(` ┌ [convert] unpacked sourcemap: ${sourcePath} (${unpackedFiles})`, time_start_unpack);

}

const time_start_convert = Date.now();

const dataList = generateV8DataList(stateList, options);
const dataFiles = EC.cyan(`${dataList.v8DataList.length} files`);

Expand Down
6 changes: 1 addition & 5 deletions lib/platform/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,7 @@ const Util = {
}

if (ms < 60 * 1000) {
const ss = Math.floor(ms / 1000);
const sms = Math.round((ms - ss * 1000) / 100);
if (sms) {
return `${ss}.${sms}${space}s`;
}
const ss = parseFloat((ms / 1000).toFixed(1));
return `${ss}${space}s`;
}

Expand Down

0 comments on commit 36ec190

Please sign in to comment.