MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / run_hello_world

Function run_hello_world

benches/memory_usage.py:445–473  ·  view source on GitHub ↗

Measure RSS for a trivial single-file PHP project. Returns RSS in KiB.

(binary: str, work_dir: str)

Source from the content-addressed store, hash-verified

443
444
445def run_hello_world(binary: str, work_dir: str) -> int:
446 """Measure RSS for a trivial single-file PHP project.
447
448 Returns RSS in KiB.
449 """
450 project_dir = os.path.join(work_dir, "hello_project")
451 os.makedirs(project_dir, exist_ok=True)
452
453 php_file = os.path.join(project_dir, "hello.php")
454 with open(php_file, "w") as f:
455 f.write(HELLO_WORLD_PHP)
456
457 client = LspClient(binary, project_dir)
458 try:
459 client.initialize()
460 client.wait_for_indexing(timeout=30)
461
462 file_uri = Path(php_file).as_uri()
463 client.did_open(file_uri, HELLO_WORLD_PHP)
464
465 # Hover over ``array_map`` (line 3, col 11) to force the server
466 # to load stubs and resolve types before we measure memory.
467 client.hover(file_uri, line=3, character=11)
468 client.drain_notifications(SETTLE_TIME)
469
470 rss = sample_rss(client.pid)
471 return rss
472 finally:
473 client.shutdown()
474
475
476def setup_laravel(work_dir: str) -> str:

Callers 1

mainFunction · 0.85

Calls 10

initializeMethod · 0.95
wait_for_indexingMethod · 0.95
did_openMethod · 0.95
hoverMethod · 0.95
drain_notificationsMethod · 0.95
shutdownMethod · 0.95
LspClientClass · 0.85
sample_rssFunction · 0.85
writeMethod · 0.80
openFunction · 0.50

Tested by

no test coverage detected