MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_callgrind

Method run_callgrind

ci/profile_runner.py:458–589  ·  view source on GitHub ↗

Run callgrind analysis

(self)

Source from the content-addressed store, hash-verified

456 return False
457
458 def run_callgrind(self) -> bool:
459 """Run callgrind analysis"""
460 print("\nRunning callgrind analysis...")
461
462 if self.use_docker:
463 # Docker mode: Run callgrind using test system infrastructure
464 # The test system uses Docker volumes, so we need to use test.py to access them
465 print("🐳 Running callgrind inside Docker container...")
466 try:
467 # Run a custom callgrind wrapper script inside Docker
468 # Use test.py's Docker infrastructure to ensure volume access
469 callgrind_script = f"""
470#!/bin/bash
471set -e
472cd /fastled
473BINARY=.build/meson-{self.build_mode}/tests/profile/{self.test_name}
474if [ ! -f "$BINARY" ]; then
475 echo "Error: Binary not found at $BINARY"
476 ls -la .build/meson-{self.build_mode}/tests/profile/ || true
477 exit 1
478fi
479echo "Running callgrind on $BINARY..."
480echo "Build mode: {self.build_mode} (DWARF4 debug symbols for Valgrind 3.19 compatibility)"
481# Run callgrind directly on binary with DWARF4 symbols
482valgrind --tool=callgrind \\
483 --callgrind-out-file=/fastled/callgrind.out \\
484 "$BINARY" baseline
485echo "Callgrind complete! Output: callgrind.out"
486ls -lh /fastled/callgrind.out
487"""
488 # Write script to temp file with Unix line endings (LF only)
489 script_path = Path("_callgrind_temp.sh")
490 script_path.write_text(callgrind_script, newline="\n")
491
492 # Run via Docker with same volumes as test system
493 print(
494 f" Docker volume: fastled-docker-build-{self._get_project_hash()}"
495 )
496 result = subprocess.run(
497 [
498 "docker",
499 "run",
500 "--rm",
501 "-v",
502 f"{Path.cwd().as_posix()}:/fastled",
503 "-v",
504 f"fastled-docker-build-{self._get_project_hash()}:/fastled/.build",
505 "fastled-unit-tests",
506 "bash",
507 "/fastled/_callgrind_temp.sh",
508 ],
509 capture_output=False, # Show output in real-time
510 check=False,
511 timeout=300,
512 )
513
514 # Cleanup temp script (keep on error for debugging)
515 if result.returncode == 0:

Callers 1

runMethod · 0.95

Calls 6

_get_project_hashMethod · 0.95
get_binary_pathMethod · 0.95
unlinkMethod · 0.80
printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected