# speedline-core

> Get the speed index from chrome dev tool timeline files

Latest version **1.4.3** (published 2020-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install speedline-core
pnpm add speedline-core
yarn add speedline-core
bun add speedline-core
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2020-07-28 |
| First published | 2018-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0 |
| Dependencies | 3 |
| Unpacked size | 139.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 811 |
| Maintainers | paulirish |
| Keywords | chrome, devtools, timeline, speed, index, performance |

## Links

- npm: https://www.npmjs.com/package/speedline-core
- Repository: https://github.com/paulirish/speedline
- Homepage: https://github.com/paulirish/speedline#readme
- Issues: https://github.com/paulirish/speedline/issues
- npm.io page: https://npm.io/package/speedline-core

## Dependencies (3)

- [jpeg-js](https://npm.io/package/jpeg-js.md) ^0.4.1
- [image-ssim](https://npm.io/package/image-ssim.md) ^0.2.0
- [@types/node](https://npm.io/package/@types/node.md) *

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.4.3 (latest) — 2020-07-28
- 1.4.2 — 2018-09-20
- 1.4.0 — 2018-08-07

## README

# speedline-core

This is the core module for speedline, without any CLI dependencies. See [speedline](https://github.com/paulirish/speedline) for the CLI.

### Install

```bash
$ npm install speedline
```

### Usage

```js
const speedline = require('speedline-core');

speedline('./timeline').then(results => {
  console.log('Speed Index value:', results.speedIndex);
});
```

### API

#### `speedline(timeline [, opts])`

* (string | object[]) `timeline`
* (object) `opts`

Returns a (Promise) resolving with an object containing:
  * `beginning` (number) - Recording start timestamp
  * `end` (number) - Recording end timestamp
  * `speedIndex` (number) - speed index value.
  * `perceptualSpeedIndex` (number) - perceptual speed index value.
  * `first` (number) - duration before the first visual change in ms.
  * `complete` (number) - duration before the last visual change in ms.
  * `duration` (number) - timeline recording duration in ms.
  * `frames` ([Frame](#frame)[]) - array of all the frames extracted from the timeline.

**`timeline` parameter**:
* `string` - the parameter represents the location of the of file containing the timeline.
* `array` - the parameter represents the traceEvents content of the timeline file.

**`opts` parameter**:
* `timeOrigin`: Provides the baseline timeStamp, typically navigationStart. Must be a monotonic clock timestamp that matches the trace.  E.g. `speedline('trace.json', {timeOrigin: 103205446186})`
* `fastMode`: If the elapsed time and difference in similarity between two screenshots are small, fastMode will skip decoding and evaluating the frames between them.
* `include`: Specifies which speed indexes to compute, can be one of `all|speedIndex|perceptualSpeedIndex`, defaults to `all`.

#### `Frame`

Object representing a single screenshot.

* `frame.getHistogram()`: (number[][]) - returns the frame histogram. Note that light pixels informations are removed from the histogram, for better speed index calculation accuracy.
* `frame.getTimeStamp()`: (number) - return the frame timestamp.
* `frame.getImage()`: (Buffer) - return the frame content.
* `frame.getProgress()`: (number) - return the frame visual progress.
* `frame.getPerceptualProgress()`: (number) - return the frame perceptual visual progress.


## License

MIT © [Pierre-Marie Dartus](https://github.com/pmdartus)

---
_Source: https://npm.io/package/speedline-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
