@@ -713,24 +713,80 @@ const andromedaConsole = {
713713 } ,
714714
715715 /**
716- * Starts a profile
716+ * Starts a JavaScript CPU profile with an optional label.
717+ * Following WHATWG Console specification.
718+ *
719+ * Note: In browser DevTools, this would start CPU profiling.
720+ * In Andromeda, we log the profile start event.
721+ *
722+ * @example
723+ * ```ts
724+ * console.profile("MyProfile");
725+ * // ... code to profile
726+ * console.profileEnd("MyProfile");
727+ * ```
717728 */
718- profile ( _label ?: string ) {
719- // TODO: implement profiling if needed
729+ profile ( label ?: string ) {
730+ label = label !== undefined
731+ ? webidl . converters . DOMString ( label , "console.profile" , "Argument 1" )
732+ : "" ;
733+
734+ const profileLabel = label || "Profile" ;
735+ const message = `Profile '${ profileLabel } ' started` ;
736+ andromedaConsole . info ( message ) ;
720737 } ,
721738
722739 /**
723- * Ends a profile
740+ * Stops the JavaScript CPU profile with the specified label.
741+ * Following WHATWG Console specification.
742+ *
743+ * @example
744+ * ```ts
745+ * console.profile("MyProfile");
746+ * // ... code to profile
747+ * console.profileEnd("MyProfile");
748+ * ```
724749 */
725- profileEnd ( _label ?: string ) {
726- // TODO: implement profiling end if needed
750+ profileEnd ( label ?: string ) {
751+ label = label !== undefined
752+ ? webidl . converters . DOMString (
753+ label ,
754+ "console.profileEnd" ,
755+ "Argument 1" ,
756+ )
757+ : "" ;
758+
759+ const profileLabel = label || "Profile" ;
760+ const message = `Profile '${ profileLabel } ' finished` ;
761+ andromedaConsole . info ( message ) ;
727762 } ,
728763
729764 /**
730- * Adds a timestamp to the console
765+ * Adds a timestamp marker to the browser's Performance or Waterfall tool.
766+ * Following WHATWG Console specification.
767+ *
768+ * In Andromeda, this logs a timestamp with the current time in milliseconds.
769+ *
770+ * @example
771+ * ```ts
772+ * console.timeStamp("checkpoint-1");
773+ * // ... some code
774+ * console.timeStamp("checkpoint-2");
775+ * ```
731776 */
732- timeStamp ( _label ?: string ) {
733- // TODO: implement timestamp if needed
777+ timeStamp ( label ?: string ) {
778+ label = label !== undefined
779+ ? webidl . converters . DOMString (
780+ label ,
781+ "console.timeStamp" ,
782+ "Argument 1" ,
783+ )
784+ : "" ;
785+
786+ const timestamp = Date . now ( ) ;
787+ const timestampLabel = label || "timestamp" ;
788+ const message = `${ timestampLabel } : ${ timestamp } ms` ;
789+ andromedaConsole . info ( message ) ;
734790 } ,
735791} ;
736792
0 commit comments