Repository navigation
profile_time(): time a block's script and geometry, or an expression - #236
Merged
Merged
Conversation
profile_time([label]) { ... } prints
PROFILE: label: T (script S, geometry G)
and x = profile_time([label]) expr; prints PROFILE: label: T and
evaluates to expr's value. Times under 1 ms print in microseconds.
Script time is taken around the resolve call in evalModularCall and
kept on CSGNode::profileScriptMs, outside cacheKey() so profiling never
defeats the ManifoldCache. Geometry time is taken in generateTreeImpl
from before the cache lookup, so a hit reports 'geometry cached'; a hit
on an ancestor walks its subtree for profile_time() nodes (only when
the run has any). A resolve-only run reports script time alone. The
expression form is interpreter-only (NotCompilable) and kept out of
simplifyTailStep so the clock stops after the body. PROFILE lines go
straight to the echo callback, never into cached warnings.
supported_feature("profile-time") is 1. Parser: openscad_cpp_parser
#14 (submodule bumped to it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Evaluator half of
profile_time(). Needs BelfrySCAD/openscad_cpp_parser#14 (the submodule points at its commit).Behaviour
label=); defaultline N of file. Evaluated before the clock starts.geometry cached— also when the hit is on an ancestor, which never visits the profile_time() node.evaluate(generate=false)):script S (no geometry built).supported_feature("profile-time")= 1.Implementation
evalModularCall; stored onCSGNode::profileScriptMs, not incacheKey().generateTreeImpl, from before the cache lookup. Ancestor hits walk the subtree viareportCachedProfiles, only when the run resolved any profile_time() (profileNodeCount_), so other models pay nothing.evalProfileTimeExpr; the bytecode compiler has no case, so a containing function falls back to the interpreter; deliberately absent fromsimplifyTailStep.PROFILE:lines go to the echo callback directly, never into cached warnings (a replay would print a stale time).CLAUDE.md§ profile_time().Testing
tests/test_profile_time.cpp(11): value passthrough, inside a function, default label, module form both times, named label, cache hit, ancestor cache hit, resolve-only, feature flag, VM forced on, µs formatting. C++ suite 2040/2040.🤖 Generated with Claude Code