
Xcode Build Benchmark
- 2.8k installs
- 1.2k repo stars
- Updated April 15, 2026
- avdlee/xcode-build-optimization-agent-skill
xcode-build-benchmark is an agent skill that runs repeatable Xcode clean and incremental build timings and saves median results to .build-benchmark JSON artifacts.
About
xcode-build-benchmark is an agent skill for producing repeatable Xcode build baselines before optimization work begins. It collects workspace or project path, scheme, configuration, destination, and whether simulator or device numbers are needed, then normalizes xcodebuild flags that affect caching. The default workflow warms up once, runs three clean builds, optionally three cached clean builds when COMPILATION_CACHE_ENABLE_CACHING is YES, three zero-change builds to measure fixed overhead, and optional incremental builds after touching a representative Swift file via --touch-file. Results save medians, min, and max timings plus environment details into timestamped JSON under .build-benchmark using scripts/benchmark_builds.py when available. Worktree users must create missing SPM exclude directories such as __Snapshots__ before resolvePackageDependencies to avoid xcodebuild crashes. The skill forbids modifying project files during measurement and reports biggest timing-summary categories from -showBuildTimingSummary output. When users only want numbers, it stops after measurement; optimization handoffs route to sibling skills like xcode-compilation-analyzer or spm-build-analysis.
- Measures clean, cached clean, zero-change, and optional incremental builds separately.
- Uses benchmark_builds.py with medians and spread instead of single fastest runs.
- Writes timestamped JSON artifacts to .build-benchmark for before-and-after comparisons.
- Worktree guidance creates missing SPM exclude directories before package resolution.
- Hands off saved artifacts to xcode-compilation-analyzer or spm-build-analysis for optimization.
Xcode Build Benchmark by the numbers
- 2,814 all-time installs (skills.sh)
- +63 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #56 of 1,453 DevOps & CI/CD skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
xcode-build-benchmark capabilities & compatibility
- Capabilities
- normalized xcodebuild command collection with co · clean, cached clean, zero change, and incrementa · median min max reporting from multiple measured · timestamped json artifact export under .build be · handoff routing to specialized xcode optimizatio
- Use cases
- ci cd · testing · debugging
- Platforms
- macOS
What xcode-build-benchmark says it does
Run 3 zero-change builds (build immediately after a successful build with no edits)
npx skills add https://github.com/avdlee/xcode-build-optimization-agent-skill --skill xcode-build-benchmarkAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2.8k |
|---|---|
| repo stars | ★ 1.2k |
| Security audit | 3 / 3 scanners passed |
| Last updated | April 15, 2026 |
| Repository | avdlee/xcode-build-optimization-agent-skill ↗ |
How do I get a trustworthy before-and-after baseline for Xcode build times without changing project files during measurement?
Benchmark Xcode clean, cached clean, zero-change, and incremental builds with repeatable commands and timestamped .build-benchmark JSON artifacts.
Who is it for?
iOS developers comparing build performance across branches, settings, or optimization experiments on Xcode workspaces.
Skip if: Skip when you need Android or non-Xcode build systems or immediate code changes without a measured baseline first.
When should I use this skill?
User asks to benchmark Xcode builds, measure build duration, compare clean versus incremental times, or baseline before optimization.
What you get
Median clean, cached clean, zero-change, and optional incremental timings plus saved JSON artifact path and timing-summary categories.
- .build-benchmark JSON timing artifact
- median clean and incremental timing report
By the numbers
- [object Object]
- [object Object]
- [object Object]
Files
Xcode Build Benchmark
Use this skill to produce a repeatable Xcode build baseline before anyone tries to optimize build times.
Core Rules
- Measure before recommending changes.
- Capture clean and incremental builds separately.
- Keep the command, destination, configuration, scheme, and warm-up rules consistent across runs.
- Write a timestamped JSON artifact to
.build-benchmark/. - Do not change project files as part of benchmarking.
Inputs To Collect
Confirm or infer:
- workspace or project path
- scheme
- configuration
- destination
- whether the user wants simulator or device numbers
- whether a custom
DerivedDatapath is needed
If the project has both clean-build and incremental-build pain, benchmark both. That is the default.
Worktree Considerations
When benchmarking inside a git worktree, SPM packages with exclude: paths that reference gitignored directories (e.g., __Snapshots__) will cause xcodebuild -resolvePackageDependencies to crash. Create those missing directories before running any builds.
Default Workflow
1. Normalize the build command and note every flag that affects caching or module reuse. 2. Run one warm-up build if needed to validate that the command succeeds. 3. Run 3 clean builds. 4. If COMPILATION_CACHE_ENABLE_CACHING = YES is detected, run 3 cached clean builds. These measure clean build time with a warm compilation cache -- the realistic scenario for branch switching, pulling changes, or Clean Build Folder. The script handles this automatically by building once to warm the cache, then deleting DerivedData (but not the compilation cache) before each measured run. Pass --no-cached-clean to skip. 5. Run 3 zero-change builds (build immediately after a successful build with no edits). This measures the fixed overhead floor: dependency computation, project description transfer, build description creation, script phases, codesigning, and validation. A zero-change build that takes more than a few seconds indicates avoidable per-build overhead. Use the default benchmark_builds.py invocation (no --touch-file flag). 6. Optionally run 3 incremental builds with a file touch to measure a real edit-rebuild loop. Use --touch-file path/to/SomeFile.swift to touch a representative source file before each build. 7. Save the raw results and summary into .build-benchmark/. 8. Report medians and spread, not just the single fastest run.
Preferred Command Path
Use the shared helper when possible:
python3 scripts/benchmark_builds.py \
--workspace App.xcworkspace \
--scheme MyApp \
--configuration Debug \
--destination "platform=iOS Simulator,name=iPhone 16" \
--output-dir .build-benchmarkIf you cannot use the helper script, run equivalent xcodebuild commands with -showBuildTimingSummary and preserve the raw output.
Required Output
Return:
- clean build median, min, max
- cached clean build median, min, max (when COMPILATION_CACHE_ENABLE_CACHING is enabled)
- zero-change build median, min, max (fixed overhead floor)
- incremental build median, min, max (if
--touch-filewas used) - biggest timing-summary categories
- environment details that could affect comparisons
- path to the saved artifact
If results are noisy, say so and recommend rerunning under calmer conditions.
When To Stop
Stop after measurement if the user only asked for benchmarking. If they want optimization guidance, hand off the artifact to the relevant specialist by reading its SKILL.md and applying its workflow to the same project context:
- `xcode-compilation-analyzer`
- `xcode-project-analyzer`
- `spm-build-analysis`
- `xcode-build-orchestrator` for full orchestration
Additional Resources
- For the benchmark contract, see references/benchmarking-workflow.md
- For the shared artifact format, see references/benchmark-artifacts.md
- For the JSON schema, see schemas/build-benchmark.schema.json
Benchmark Artifacts
All skills in this repository should treat .build-benchmark/ as the canonical location for measured build evidence.
Goals
- Keep build measurements reproducible.
- Make clean and incremental build data easy to compare.
- Preserve enough context for later specialist analysis without rerunning the benchmark.
Wall-Clock vs Cumulative Task Time
The duration_seconds field on each run and the median_seconds in the summary represent wall-clock time -- how long the developer actually waits. This is the primary success metric.
The timing_summary_categories are aggregated task times parsed from Xcode's Build Timing Summary. Because Xcode runs many tasks in parallel across CPU cores, these totals typically exceed the wall-clock duration. A large cumulative SwiftCompile value is diagnostic evidence of compiler workload, not proof that compilation is blocking the build. Always compare category totals against the wall-clock median before concluding that a category is a bottleneck.
File Layout
Recommended outputs:
.build-benchmark/<timestamp>-<scheme>.json.build-benchmark/<timestamp>-<scheme>-clean-1.log.build-benchmark/<timestamp>-<scheme>-clean-2.log.build-benchmark/<timestamp>-<scheme>-clean-3.log.build-benchmark/<timestamp>-<scheme>-cached-clean-1.log(when COMPILATION_CACHE_ENABLE_CACHING is enabled).build-benchmark/<timestamp>-<scheme>-cached-clean-2.log.build-benchmark/<timestamp>-<scheme>-cached-clean-3.log.build-benchmark/<timestamp>-<scheme>-incremental-1.log.build-benchmark/<timestamp>-<scheme>-incremental-2.log.build-benchmark/<timestamp>-<scheme>-incremental-3.log
Use an ISO-like UTC timestamp without spaces so the files sort naturally.
Artifact Requirements
Each JSON artifact should include:
- schema version
- creation timestamp
- project context
- environment details when available
- the normalized build command
- separate
cleanandincrementalrun arrays - summary statistics for each build type
- parsed timing-summary categories
- free-form notes for caveats or noise
Clean, Cached Clean, And Incremental Separation
Do not merge different build type measurements into a single list. They answer different questions:
- Clean builds show full build-system, package, and module setup cost with a cold compilation cache.
- Cached clean builds show clean build cost when the compilation cache is warm. This is the realistic scenario for branch switching, pulling changes, or Clean Build Folder. Only present when
COMPILATION_CACHE_ENABLE_CACHING = YESis detected. - Incremental builds show edit-loop productivity and script or cache invalidation problems.
Raw Logs
Store raw xcodebuild output beside the JSON artifact whenever possible. That allows later skills to:
- re-parse timing summaries
- inspect failed builds
- search for long type-check warnings
- correlate build-system phases with recommendations
Measurement Caveats
COMPILATION_CACHE_ENABLE_CACHING
COMPILATION_CACHE_ENABLE_CACHING = YES stores compiled artifacts in a system-managed cache outside DerivedData so that repeated compilations of identical inputs are served from cache. The standard clean-build benchmark (xcodebuild clean between runs) may add overhead from cache population without showing the corresponding cache-hit benefit.
The benchmark script automatically detects COMPILATION_CACHE_ENABLE_CACHING = YES and runs a cached clean benchmark phase. This phase:
1. Builds once to warm the compilation cache. 2. Deletes DerivedData (but not the compilation cache) before each measured run. 3. Rebuilds, measuring the cache-hit clean build time.
The cached clean metric captures the realistic developer experience: branch switching, pulling changes, and Clean Build Folder. Use the cached clean median as the primary comparison metric when evaluating COMPILATION_CACHE_ENABLE_CACHING impact.
To skip this phase, pass --no-cached-clean.
First-Run Variance
The first clean build after the warmup cycle often runs 20-40% slower than subsequent clean builds due to cold OS-level caches (disk I/O, dynamic linker cache, etc.). The benchmark script mitigates this by running a warmup clean+build cycle before measured runs. If variance between the first and later clean runs is still high, prefer the median or min over the mean, and note the variance in the artifact's notes field.
Shared Consumer Expectations
Any skill reading a benchmark artifact should be able to identify:
- what was measured
- how it was measured
- whether the run succeeded
- whether the results are stable enough to compare
For the authoritative field-level schema, see ../schemas/build-benchmark.schema.json.
Benchmarking Workflow
Use this reference when you need the full operational contract for collecting Xcode build measurements.
Goal
Produce a benchmark artifact that another skill can trust without rerunning the same setup discovery.
Benchmark Contract
- Measure both clean and incremental builds unless the user narrows the scope.
- Use the same scheme, configuration, destination, and command flags for all measured runs.
- Record the exact command and any environment overrides.
- Keep clean and incremental runs in separate arrays in the artifact.
- Save wall-clock timing plus any parsed timing-summary categories.
Suggested Run Counts
- Clean builds: 3 measured runs
- Incremental builds: 3 measured runs
- Warm-up: 0 to 1 validation run, excluded from the summary unless the user explicitly wants it included
Clean Build Rules
- Clear build products with
xcodebuild cleanor an equivalent clean-build-folder step before each measured clean run. - Do not change scheme, destination, or configuration between runs.
- If the command fails, store the failure and stop rather than mixing failed and successful runs.
Incremental Build Rules
- Use the same build command after a successful baseline build.
- Do not clean between incremental runs.
- If the user wants edit-loop benchmarking, note the file change strategy explicitly in the artifact.
- If there are no source edits between runs, label the result as no-edit incremental timing.
What To Capture
At minimum, keep:
- timestamp
- host machine info if available
- Xcode version if available
- workspace or project path
- scheme, configuration, destination
- exact
xcodebuildcommand - duration per run
- success or failure
- parsed timing-summary categories
- notes on warm-up behavior or unusual noise
Reporting Guidance
Use medians for the headline number. Also include:
- min and max
- range
- category totals from the timing summary
- obvious outliers or instability
Handoff Expectations
The next optimization skill should be able to answer:
- Is the main problem clean, incremental, or both?
- Which build categories dominate time?
- Which command produced the evidence?
- Is the baseline trustworthy enough to compare before and after changes?
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Xcode Build Benchmark Artifact",
"type": "object",
"required": [
"schema_version",
"created_at",
"build",
"runs",
"summary"
],
"properties": {
"schema_version": {
"type": "string",
"enum": ["1.0.0", "1.1.0", "1.2.0"]
},
"created_at": {
"type": "string",
"format": "date-time"
},
"build": {
"type": "object",
"required": [
"entrypoint",
"scheme",
"configuration",
"destination",
"command"
],
"properties": {
"entrypoint": {
"type": "string",
"enum": [
"project",
"workspace"
]
},
"path": {
"type": "string"
},
"scheme": {
"type": "string"
},
"configuration": {
"type": "string"
},
"destination": {
"type": "string"
},
"derived_data_path": {
"type": "string"
},
"command": {
"type": "string"
}
},
"additionalProperties": true
},
"environment": {
"type": "object",
"properties": {
"host": {
"type": "string"
},
"xcode_version": {
"type": "string"
},
"macos_version": {
"type": "string"
}
},
"additionalProperties": true
},
"runs": {
"type": "object",
"required": [
"clean",
"incremental"
],
"properties": {
"clean": {
"type": "array",
"items": {
"$ref": "#/definitions/run"
}
},
"cached_clean": {
"type": "array",
"items": {
"$ref": "#/definitions/run"
}
},
"incremental": {
"type": "array",
"items": {
"$ref": "#/definitions/run"
}
}
},
"additionalProperties": false
},
"summary": {
"type": "object",
"required": [
"clean",
"incremental"
],
"properties": {
"clean": {
"$ref": "#/definitions/stats"
},
"cached_clean": {
"$ref": "#/definitions/stats"
},
"incremental": {
"$ref": "#/definitions/stats"
}
},
"additionalProperties": false
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
}
},
"definitions": {
"run": {
"type": "object",
"required": [
"id",
"build_type",
"duration_seconds",
"success",
"command"
],
"properties": {
"id": {
"type": "string"
},
"build_type": {
"type": "string",
"enum": [
"clean",
"cached-clean",
"incremental"
]
},
"duration_seconds": {
"type": "number",
"minimum": 0
},
"success": {
"type": "boolean"
},
"command": {
"type": "string"
},
"exit_code": {
"type": "integer"
},
"raw_log_path": {
"type": "string"
},
"timing_summary_categories": {
"type": "array",
"items": {
"$ref": "#/definitions/category"
}
}
},
"additionalProperties": true
},
"category": {
"type": "object",
"required": [
"name",
"seconds"
],
"properties": {
"name": {
"type": "string"
},
"seconds": {
"type": "number",
"minimum": 0
},
"task_count": {
"type": "integer",
"minimum": 0
}
},
"additionalProperties": true
},
"stats": {
"type": "object",
"required": [
"count",
"min_seconds",
"max_seconds",
"median_seconds",
"average_seconds"
],
"properties": {
"count": {
"type": "integer",
"minimum": 0
},
"min_seconds": {
"type": "number",
"minimum": 0
},
"max_seconds": {
"type": "number",
"minimum": 0
},
"median_seconds": {
"type": "number",
"minimum": 0
},
"average_seconds": {
"type": "number",
"minimum": 0
}
},
"additionalProperties": true
}
}
}
#!/usr/bin/env python3
import argparse
import json
import os
import platform
import re
import shutil
import statistics
import subprocess
import sys
import tempfile
import time
from datetime import datetime, timezone
from pathlib import Path
from typing import Dict, List, Optional
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Benchmark Xcode clean and incremental builds.")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--workspace", help="Path to the .xcworkspace file")
group.add_argument("--project", help="Path to the .xcodeproj file")
parser.add_argument("--scheme", required=True, help="Scheme to build")
parser.add_argument("--configuration", default="Debug", help="Build configuration")
parser.add_argument("--destination", help="xcodebuild destination string")
parser.add_argument("--derived-data-path", help="DerivedData path override")
parser.add_argument("--output-dir", default=".build-benchmark", help="Output directory for artifacts")
parser.add_argument("--repeats", type=int, default=3, help="Measured runs per build type")
parser.add_argument("--skip-warmup", action="store_true", help="Skip the validation build")
parser.add_argument(
"--touch-file",
help="Path to a source file to touch before each incremental build. "
"When provided, measures a real edit-rebuild loop instead of a zero-change build.",
)
parser.add_argument(
"--no-cached-clean",
action="store_true",
help="Skip cached clean builds even when COMPILATION_CACHE_ENABLE_CACHING is detected.",
)
parser.add_argument(
"--extra-arg",
action="append",
default=[],
help="Additional xcodebuild argument to append. Can be passed multiple times.",
)
return parser.parse_args()
def command_base(args: argparse.Namespace) -> List[str]:
command = ["xcodebuild"]
if args.workspace:
command.extend(["-workspace", args.workspace])
if args.project:
command.extend(["-project", args.project])
command.extend(["-scheme", args.scheme, "-configuration", args.configuration])
if args.destination:
command.extend(["-destination", args.destination])
if args.derived_data_path:
command.extend(["-derivedDataPath", args.derived_data_path])
command.extend(args.extra_arg)
return command
def shell_join(parts: List[str]) -> str:
return " ".join(subprocess.list2cmdline([part]) for part in parts)
_TASK_COUNT_RE = re.compile(r"^(.+?)\s*\((\d+)\s+tasks?\)$")
def _extract_task_count(name: str) -> tuple[str, Optional[int]]:
"""Split 'Category (N tasks)' into ('Category', N)."""
match = _TASK_COUNT_RE.match(name)
if match:
return match.group(1).strip(), int(match.group(2))
return name, None
def parse_timing_summary(output: str) -> List[Dict]:
categories: Dict[str, float] = {}
task_counts: Dict[str, Optional[int]] = {}
for raw_line in output.splitlines():
line = raw_line.strip()
if not line:
continue
for suffix in (" seconds", " second", " sec"):
if not line.endswith(suffix):
continue
trimmed = line[: -len(suffix)]
if "|" in trimmed:
name_part, _, seconds_text = trimmed.rpartition("|")
else:
name_part, _, seconds_text = trimmed.rpartition(" ")
try:
seconds = float(seconds_text.strip())
except ValueError:
continue
cleaned_name = name_part.replace(" ", " ").strip(" -:")
if len(cleaned_name) < 3:
continue
base_name, count = _extract_task_count(cleaned_name)
categories[base_name] = categories.get(base_name, 0.0) + seconds
if count is not None:
task_counts[base_name] = (task_counts.get(base_name) or 0) + count
break
result: List[Dict] = []
for name, seconds in sorted(categories.items(), key=lambda item: item[1], reverse=True):
entry: Dict = {"name": name, "seconds": round(seconds, 3)}
if name in task_counts:
entry["task_count"] = task_counts[name]
result.append(entry)
return result
def run_command(command: List[str]) -> subprocess.CompletedProcess:
return subprocess.run(command, capture_output=True, text=True)
def stats_for(runs: List[Dict[str, object]]) -> Dict[str, float]:
durations = [run["duration_seconds"] for run in runs if run.get("success")]
if not durations:
return {
"count": 0,
"min_seconds": 0.0,
"max_seconds": 0.0,
"median_seconds": 0.0,
"average_seconds": 0.0,
}
return {
"count": len(durations),
"min_seconds": round(min(durations), 3),
"max_seconds": round(max(durations), 3),
"median_seconds": round(statistics.median(durations), 3),
"average_seconds": round(statistics.fmean(durations), 3),
}
def xcode_version() -> str:
result = run_command(["xcodebuild", "-version"])
return result.stdout.strip() if result.returncode == 0 else "unknown"
def detect_compilation_caching(base_command: List[str]) -> bool:
"""Check whether COMPILATION_CACHE_ENABLE_CACHING is enabled in the resolved build settings."""
result = run_command([*base_command, "-showBuildSettings"])
if result.returncode != 0:
return False
for line in result.stdout.splitlines():
stripped = line.strip()
if stripped.startswith("COMPILATION_CACHE_ENABLE_CACHING") and "=" in stripped:
value = stripped.split("=", 1)[1].strip()
return value == "YES"
return False
def measure_build(
base_command: List[str],
artifact_stem: str,
output_dir: Path,
build_type: str,
run_index: int,
) -> Dict[str, object]:
build_command = [*base_command, "build", "-showBuildTimingSummary"]
started = time.perf_counter()
result = run_command(build_command)
elapsed = round(time.perf_counter() - started, 3)
log_path = output_dir / f"{artifact_stem}-{build_type}-{run_index}.log"
log_path.write_text(result.stdout + result.stderr)
return {
"id": f"{build_type}-{run_index}",
"build_type": build_type,
"duration_seconds": elapsed,
"success": result.returncode == 0,
"exit_code": result.returncode,
"command": shell_join(build_command),
"raw_log_path": str(log_path),
"timing_summary_categories": parse_timing_summary(result.stdout + result.stderr),
}
def main() -> int:
args = parse_args()
output_dir = Path(args.output_dir)
output_dir.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
artifact_stem = f"{timestamp}-{args.scheme.replace(' ', '-').lower()}"
base_command = command_base(args)
if not args.skip_warmup:
warmup = run_command([*base_command, "build"])
if warmup.returncode != 0:
sys.stderr.write(warmup.stdout + warmup.stderr)
return warmup.returncode
warmup_clean = run_command([*base_command, "clean"])
if warmup_clean.returncode != 0:
sys.stderr.write(warmup_clean.stdout + warmup_clean.stderr)
return warmup_clean.returncode
warmup_rebuild = run_command([*base_command, "build"])
if warmup_rebuild.returncode != 0:
sys.stderr.write(warmup_rebuild.stdout + warmup_rebuild.stderr)
return warmup_rebuild.returncode
runs: Dict[str, list] = {"clean": [], "incremental": []}
for index in range(1, args.repeats + 1):
clean_result = run_command([*base_command, "clean"])
clean_log_path = output_dir / f"{artifact_stem}-clean-prep-{index}.log"
clean_log_path.write_text(clean_result.stdout + clean_result.stderr)
if clean_result.returncode != 0:
sys.stderr.write(clean_result.stdout + clean_result.stderr)
return clean_result.returncode
runs["clean"].append(measure_build(base_command, artifact_stem, output_dir, "clean", index))
# --- Cached clean builds ---------------------------------------------------
# When COMPILATION_CACHE_ENABLE_CACHING is enabled, the compilation cache lives outside
# DerivedData and survives product deletion. We measure "cached clean"
# builds by pointing DerivedData at a temp directory, warming the cache with
# one build, then deleting the DerivedData directory (but not the cache)
# before each measured rebuild. This captures the realistic scenario:
# branch switching, pulling changes, or Clean Build Folder.
should_cached_clean = not args.no_cached_clean and detect_compilation_caching(base_command)
if should_cached_clean:
dd_path = Path(args.derived_data_path) if args.derived_data_path else Path(
tempfile.mkdtemp(prefix="xcode-bench-dd-")
)
cached_cmd = list(base_command)
if not args.derived_data_path:
cached_cmd.extend(["-derivedDataPath", str(dd_path)])
cache_warmup = run_command([*cached_cmd, "build"])
if cache_warmup.returncode != 0:
sys.stderr.write("Warning: cached clean warmup build failed, skipping cached clean benchmarks.\n")
sys.stderr.write(cache_warmup.stdout + cache_warmup.stderr)
should_cached_clean = False
if should_cached_clean:
runs["cached_clean"] = []
for index in range(1, args.repeats + 1):
shutil.rmtree(dd_path, ignore_errors=True)
runs["cached_clean"].append(
measure_build(cached_cmd, artifact_stem, output_dir, "cached-clean", index)
)
shutil.rmtree(dd_path, ignore_errors=True)
# --- Incremental / zero-change builds --------------------------------------
incremental_label = "incremental"
if args.touch_file:
touch_path = Path(args.touch_file)
if not touch_path.exists():
sys.stderr.write(f"--touch-file path does not exist: {touch_path}\n")
return 1
incremental_label = "incremental"
else:
incremental_label = "zero-change"
for index in range(1, args.repeats + 1):
if args.touch_file:
touch_path.touch()
runs["incremental"].append(
measure_build(base_command, artifact_stem, output_dir, incremental_label, index)
)
summary: Dict[str, object] = {
"clean": stats_for(runs["clean"]),
"incremental": stats_for(runs["incremental"]),
}
if "cached_clean" in runs:
summary["cached_clean"] = stats_for(runs["cached_clean"])
artifact = {
"schema_version": "1.2.0" if "cached_clean" in runs else "1.1.0",
"created_at": datetime.now(timezone.utc).isoformat(),
"build": {
"entrypoint": "workspace" if args.workspace else "project",
"path": args.workspace or args.project,
"scheme": args.scheme,
"configuration": args.configuration,
"destination": args.destination or "",
"derived_data_path": args.derived_data_path or "",
"command": shell_join(base_command),
},
"environment": {
"host": platform.node(),
"macos_version": platform.platform(),
"xcode_version": xcode_version(),
"cwd": os.getcwd(),
},
"runs": runs,
"summary": summary,
"notes": [f"touch-file: {args.touch_file}"] if args.touch_file else [],
}
artifact_path = output_dir / f"{artifact_stem}.json"
artifact_path.write_text(json.dumps(artifact, indent=2) + "\n")
print(f"Saved benchmark artifact: {artifact_path}")
print(f"Clean median: {artifact['summary']['clean']['median_seconds']}s")
if "cached_clean" in artifact["summary"]:
print(f"Cached clean median: {artifact['summary']['cached_clean']['median_seconds']}s")
inc_label = "Incremental" if args.touch_file else "Zero-change"
print(f"{inc_label} median: {artifact['summary']['incremental']['median_seconds']}s")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
How it compares
Pick xcode-build-benchmark when you need persisted, comparable timing artifacts rather than ad-hoc `xcodebuild -showBuildTimingSummary` console output alone.
FAQ
Does benchmarking modify the Xcode project?
No. The skill explicitly forbids changing project files as part of benchmarking measurement runs.
What is a zero-change build?
A build immediately after a successful build with no edits, measuring fixed overhead like dependency computation and codesigning.
What helper script should be used?
Prefer python3 scripts/benchmark_builds.py with workspace, scheme, configuration, destination, and --output-dir .build-benchmark.
Is Xcode Build Benchmark safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.