Skip to content

Restore emitter timing instrumentation (console.time) in $onEmit for testing#3955

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-console-time-for-testing
Draft

Restore emitter timing instrumentation (console.time) in $onEmit for testing#3955
Copilot wants to merge 3 commits into
mainfrom
copilot/add-console-time-for-testing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

This PR restores the console.time / console.timeEnd instrumentation that was removed in #3483. The goal is to bring back timing visibility in the TypeSpec emitter pipeline for testing and performance observation.

  • What changed

    • Reintroduced timing markers in packages/typespec-ts/src/index.ts inside $onEmit.
    • Restored the original phase-level labels across key emitter stages (context creation, static helper loading, binder setup, RLC model build, modular source generation sub-phases, and overall emit duration).
  • Lint-scope handling

    • Kept no-console enforcement intact by applying // eslint-disable-next-line no-console only on restored timing lines, instead of broad file/function-level suppression.
  • Illustrative snippet

    // eslint-disable-next-line no-console
    console.time("onEmit: create context");
    const dpgContext = await createContextWithDefaultOptions(context);
    // eslint-disable-next-line no-console
    console.timeEnd("onEmit: create context");
Original prompt

#3483
这个pr吧console.time 给删除了,现在需要一个用来做testing的pr,需要把console.time 加回原来的位置

[Chronological Review: The conversation began with the user requesting modifications to the function `knownMediaType` to handle a specific case for the "/" character. The user then inquired about potential modifications in another file, `transformParameters.ts`, and asked various questions regarding the code logic, particularly around the handling of different content types and encoding. The user also requested to add back `console.time` in a specific pull request for testing purposes.]

[Intent Mapping:

  1. "当前代码里的'/的逻辑做进function knownMediaType里面,增加if条件,/时return KnownMediaType.Binary,并修改对应代码" - User wants to modify the knownMediaType function.
  2. "packages/typespec-ts/src/transform/transformParameters.ts 是不是也要修改?" - User is checking if another file needs modification.
  3. "为什么111行是uint8ArrayToString" - User is questioning a specific line of code.
  4. "tcgc 处理的逻辑在哪里" - User is looking for the logic related to tcgc.
  5. "什么情况会是Scalar" - User is asking about conditions for a scalar type.
  6. "SchemaContentTypeValues 是一个union,是不是算!defaultContentType" - User is inquiring about union types.
  7. "抛开*/的问题,重新分析为什么111行是uint8ArrayToString" - User wants a deeper analysis of a specific line.
  8. "为什么type.kind === 'Scalar' 且无 defaultContentType" - User is questioning a specific condition in the code.
  9. "路径一里面为什么会是这个结果" - User is asking about a specific result in the code.
  10. "那为什么有些 bytes 不会又encode base64?" - User is inquiring about encoding behavior.
  11. "那什么时候tcgc没有encode?" - User is asking about conditions when tcgc does not encode.
  12. "都会有encode那岂不是不会走到else {...}" - User is questioning the logic flow.
  13. "当前case加一个content-type是application/xml的" - User wants to add a specific content type case.
  14. "SCENARIOS_UPDATE设置为true并且跑一下这个的ut packages\typespec-ts\test\modularUnit\scenarios\operations\bodyParam\bytesWithDifferentContentType.md" - User is requesting to run a unit test with a specific setting.
  15. "Continue: 'Continue to iterate?'" - User is prompting to continue the iteration.
  16. "这个pr吧console.time给删除了,现在需要一个用来做testing的pr,需要把console.time加回原来的位置" - User is requesting to add back console.time in a specific pull request for testing.]

[Technical Inventory:

  • Function knownMediaType: Needs modification to handle "/" character.
  • File transformParameters.ts: Potential modifications discussed.
  • Content types: Various types discussed including application/xml.
  • Encoding logic: Questions raised about when encoding occurs and the behavior of tcgc.]

[Code Archaeology:

  • knownMediaType: Function to be modified.
  • transformParameters.ts: File under consideration for changes.
  • Specific lines of code questioned: Line 111 regarding uint8ArrayToString, and conditions for scalar types.]

[Progress Assessment:

  • Completed: User has made several inquiries and requests for modifications.
  • Pending: Modifications to knownMediaType, potential changes in transformParameters.ts, and adding back console.time in the PR.]

[Context Validation: All user requests and inquiries are captured, providing a clear path for continuation.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to modify the knownMediaType function and check another file for necessary changes.
  • Tool Results Summary: No specific tool results were returned as the conversation primarily consisted of user inquiries and requests.
  • Pre-Summary State: The agent was actively discussing modifications to the code and addressing user inquiries when the token budget was exceeded.
  • Operation Context: The user is focused on refining the codebase and ensuring proper handling of media types and encoding.]
1. Conversation Overview: - Primary Objectives: User requested modifications to the `knownMediaType` function to handle the "/" character and inquired about related logic in other files. User also asked various questions about encoding, content types, and specific lines of code. - Session Context: The conversation has revolved around understanding and modifying code logic, particularly in the context of media types and encoding. - User Intent Evolution: The user has shifted from specific function modifications to broader inquiries about code behavior and testing requirements.
  1. Technical Foundation:
  • Function knownMediaType: Needs to be modified to return KnownMediaType.Binary for the "/" character.
  • File transformParameters.ts: Potential modifications discussed.
  • Content Types: User wants to add handling for application/xml.
  • Encoding Logic: User is exploring when encoding occurs and the behavior of tcgc.
  1. Codebase Status:
  • File Name: index.ts
  • Purpose: Core functionality related to media type handling.
  • Current State: User is requesting modifications and clarifications on specific lines.
  • Key Code Segments: Line 111 regarding `uint8ArrayToString...

Created from VS Code.

Copilot AI and others added 2 commits May 12, 2026 06:01
Copilot AI changed the title [WIP] Add console.time back for testing purposes Restore emitter timing instrumentation (console.time) in $onEmit for testing May 12, 2026
Copilot AI requested a review from kazrael2119 May 12, 2026 06:07
@kazrael2119
Copy link
Copy Markdown
Member

#3907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants