Last active
September 7, 2025 20:29
-
-
Save smeech/dbb2ea302d9c5611107ff88a7ff365c4 to your computer and use it in GitHub Desktop.
[Interpreter comparisons] A ChatGPT-generated script to compare the startup times of several interpreters in order to estimate the likely delays when scripts are used in Espanso triggers.. #python #ruby #pwsh #node #bash #espanso #perl #php #sh
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
| # https://chatgpt.com/share/685eb2a6-8dd4-8012-9fc9-d8f0ff137773 | |
| #!/usr/bin/env python3 | |
| import subprocess | |
| import time | |
| import shutil | |
| interpreters = { | |
| "PowerShell (pwsh)": ["pwsh", "-NoProfile", "-Command", "exit"], | |
| "Ruby": ["ruby", "-e", "exit"], | |
| "Node.js": ["node", "-e", "process.exit()"], | |
| "Bash": ["bash", "-c", "exit"], | |
| "sh": ["sh", "-c", "exit"], | |
| "Python3": ["python3", "-c", "exit()"], | |
| "Perl": ["perl", "-e", "exit"], | |
| "PHP": ["php", "-r", "exit;"] | |
| } | |
| REPEATS = 10 | |
| print(f"Measuring average interpreter startup time over {REPEATS} runs...\n") | |
| for name, cmd in interpreters.items(): | |
| if not shutil.which(cmd[0]): | |
| print(f"{name:<20}: ❌ Not installed") | |
| continue | |
| durations = [] | |
| for _ in range(REPEATS): | |
| try: | |
| start = time.perf_counter() | |
| subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True) | |
| end = time.perf_counter() | |
| durations.append(end - start) | |
| except subprocess.CalledProcessError as e: | |
| print(f"{name:<20}: ❌ Error - {e}") | |
| durations = None | |
| break | |
| if durations: | |
| avg = sum(durations) / REPEATS | |
| print(f"{name:<20}: {avg:.4f} seconds (avg)") |
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
| Measuring average interpreter startup time over 10 runs... | |
| PowerShell (pwsh) : 0.3438 seconds (avg) | |
| Ruby : 0.0778 seconds (avg) | |
| Node.js : 0.0910 seconds (avg) | |
| Bash : 0.0015 seconds (avg) | |
| sh : 0.0009 seconds (avg) | |
| Python3 : 0.0255 seconds (avg) | |
| Perl : 0.0021 seconds (avg) | |
| PHP : ❌ Not installed | |
| 12 year-old PC, Linux Mint 21.2 Xfce, Intel(R) Core(TM) i3-3240 (4) @ 3.40 GHz, 24GB RAM, SSD | |
| The first run, with just one instance of each (make line 18 `REPEATS = 1`), took roughly | |
| double the times, presumably because the interpreters weren't cached in memory. This is | |
| probably more representative for Espanso triggers. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment