Why does my PerryTS project take so long to compile? #5306
-
|
I tried compiling this most basic code: import { App, VStack, Text, Button, State } from "perry/ui"
const count = State(0)
App({
title: "Counter",
width: 800,
height: 600,
body: VStack(16, [
Text(`Count: ${count.value}`),
Button("Increment", () => count.set(count.value + 1)),
]),
});It's only 13 lines of code, but running perry run took: My CPU is an i5-12100. Is this a problem on my end? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hi! Short answer: this is expected for a first build, and almost certainly not a problem with your setup. The key thing is that Perry isn't an interpreter or a TS-to-JS transpiler — it's an ahead-of-time native compiler. Those 13 lines don't run as 13 lines; they go through the full pipeline: Almost none of your 27.7s is spent on your source. The work that actually scales with "13 lines" is tiny — on my machine, compiling+linking your exact counter program is ~2 seconds. The rest is fixed cost: LLVM optimization, linking against the native UI runtime, and (the big one on a first run) Perry's auto-optimizer producing an optimized build. That cost barely changes whether your file is 13 lines or 1,300, and a The part that matters: that cost is mostly one-time. Perry caches compiled objects keyed by your source hash, so a second # First run – full compile + optimized link
Measure-Command { perry run src/main.ts } # ~27s for you
# Second run, no source change – should be a fraction of that
Measure-Command { perry run src/main.ts }Could you post the timing of that second run? That's the deciding test:
A few notes:
TL;DR: cold native+UI builds taking ~half a minute is normal; warm re-runs should be fast. Post that second-run number and we'll confirm. 👍 |
Beta Was this translation helpful? Give feedback.
Oh, I've figured out the problem. It's because the PERRY_WORKSPACE_ROOT wasn't set properly : )