Skip to content

Commit

Permalink
Track ms
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Apr 13, 2024
1 parent 7cb8172 commit 88385af
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/DocumentView/CodeBlock/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
const highlighter = await loadHighlighter();
await loadHighlighterLanguage(highlighter, langName);

const start = Date.now();
const lines = highlighter.codeToTokensBase(code, {
lang: langName,
tokenizeMaxLineLength: 120,
});
const end = Date.now() - start;

let currentIndex = 0;

console.log(
`${block.key} code len: ${code.length} lineCountBefore: ${lineCountBefore} tokenCount: ${tokenCount}`,
`${block.key} ${end - start}ms code len: ${code.length} lineCountBefore: ${lineCountBefore} tokenCount: ${tokenCount}`,
);
return lines.map((tokens, index) => {
tokenCount += tokens.length;
Expand Down

0 comments on commit 88385af

Please sign in to comment.