Measure RSS for a trivial single-file PHP project. Returns RSS in KiB.
(binary: str, work_dir: str)
| 443 | |
| 444 | |
| 445 | def 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 | |
| 476 | def setup_laravel(work_dir: str) -> str: |
no test coverage detected