# App start time

How long your app takes to start on your users' phones, per release, and which code takes the time.

Builds published with `healkite release` measure start-up when the app has the Healkite Babel plugin
(the same one [production debugging](/production-debugging) uses):

```js
// babel.config.js
plugins: ["react-native-healkite/babel"],
```

Then each release page shows **App start**:

> **1.42 s** median · +31% vs v41 · p75 1.71 s · p90 2.30 s
>
> Where the time goes (per launch): `src/analytics/index.ts` 380 ms **new** · `node_modules/react-native-reanimated` 120 ms · `src/App.tsx` 40 ms

Or in a terminal: `npx healkite startup rel_01j…`.

## How it's measured

- The build wraps each of your app's files, and each package's entry file, with two timestamps. A
  package's time includes the package's own start-up work. React Native itself isn't measured.
- The SDK loads first and counts each file's **own** time (not the files it imports) until the app
  reports ready (`Healkite.sync()` or `notifyAppReady()`).
- Start-up time is measured from when the JavaScript runtime starts to when the app reports ready.
- 1 in 5 launches sends a sample: the time plus the 25 slowest files. No user data.
- The overhead is two timer calls per measured file. Turn it off with `healkite release --no-startup-profile`.

## Stop a release that starts slower

Add a start-up limit to a guarded release. It halts, and devices go back, when the median start is more
than that much slower than the previous release, once both have enough launches:

```sh
npx healkite release -c production-… -p android -r 2.4 --guarded --guard-max-startup 20
```

In the API, it's `guard.maxStartupRegressionPct`.

## Making it faster

What usually helps, in order:

1. Move work out of the top level of files (create clients, read storage, register listeners when first
   needed, not when the file loads).
2. Import heavy packages where they're used, not in `App.tsx` or `index.js`.
3. Keep Metro's `inlineRequires` on (the React Native default), so files load on first use.
4. Check the "new" and "was" markers after each release: they point at the change that slowed it.
