@@ -22,6 +22,7 @@ import {
2222 processColorVariablesTime ,
2323 resetPerformanceCounters ,
2424} from "./altNodes/jsonNodeConversion" ;
25+ import { bench } from "./log" ;
2526
2627export const run = async ( settings : PluginSettings ) => {
2728 resetPerformanceCounters ( ) ;
@@ -44,7 +45,7 @@ export const run = async (settings: PluginSettings) => {
4445 console . log ( "convertedSelection" , convertedSelection ) ;
4546 } else {
4647 convertedSelection = await nodesToJSON ( selection , settings ) ;
47- console . log ( `[benchmark] nodesToJSON: ${ Date . now ( ) - nodeToJSONStart } ms` ) ;
48+ bench ( `[benchmark] nodesToJSON: ${ Date . now ( ) - nodeToJSONStart } ms` ) ;
4849 console . log ( "nodeJson" , convertedSelection ) ;
4950 }
5051
@@ -59,38 +60,38 @@ export const run = async (settings: PluginSettings) => {
5960
6061 const convertToCodeStart = Date . now ( ) ;
6162 const code = await convertToCode ( convertedSelection , settings ) ;
62- console . log (
63+ bench (
6364 `[benchmark] convertToCode: ${ Date . now ( ) - convertToCodeStart } ms` ,
6465 ) ;
6566
6667 const generatePreviewStart = Date . now ( ) ;
6768 const htmlPreview = await generateHTMLPreview ( convertedSelection , settings ) ;
68- console . log (
69+ bench (
6970 `[benchmark] generateHTMLPreview: ${ Date . now ( ) - generatePreviewStart } ms` ,
7071 ) ;
7172
7273 const colorPanelStart = Date . now ( ) ;
7374 const colors = retrieveGenericSolidUIColors ( framework ) ;
7475 const gradients = retrieveGenericLinearGradients ( framework ) ;
75- console . log (
76+ bench (
7677 `[benchmark] color and gradient panel: ${ Date . now ( ) - colorPanelStart } ms` ,
7778 ) ;
78- console . log (
79+ bench (
7980 `[benchmark] total generation time: ${ Date . now ( ) - nodeToJSONStart } ms` ,
8081 ) ;
8182
8283 // Log performance statistics
83- console . log (
84+ bench (
8485 `[benchmark] getNodeByIdAsync: ${ getNodeByIdAsyncTime } ms (${ getNodeByIdAsyncCalls } calls, avg: ${ ( getNodeByIdAsyncTime / getNodeByIdAsyncCalls || 1 ) . toFixed ( 2 ) } ms)` ,
8586 ) ;
86- console . log (
87+ bench (
8788 `[benchmark] getStyledTextSegments: ${ getStyledTextSegmentsTime } ms (${ getStyledTextSegmentsCalls } calls, avg: ${
8889 getStyledTextSegmentsCalls > 0
8990 ? ( getStyledTextSegmentsTime / getStyledTextSegmentsCalls ) . toFixed ( 2 )
9091 : 0
9192 } ms)`,
9293 ) ;
93- console . log (
94+ bench (
9495 `[benchmark] processColorVariables: ${ processColorVariablesTime } ms (${ processColorVariablesCalls } calls, avg: ${
9596 processColorVariablesCalls > 0
9697 ? ( processColorVariablesTime / processColorVariablesCalls ) . toFixed ( 2 )
0 commit comments