-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lucas Wojciechowski
committed
Mar 8, 2016
1 parent
d654ee3
commit dac9f84
Showing
11 changed files
with
375 additions
and
251 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Benchmarks | ||
|
||
Benchmarks help us catch performance regressions and improve performance. | ||
|
||
## Running a Benchmark | ||
|
||
Start the benchmark server | ||
|
||
```bash | ||
npm run start-bench | ||
``` | ||
|
||
Open the benchmark runner | ||
|
||
- [buffer benchmark](http://localhost:6699/bench/?benchmark=buffer) | ||
|
||
## Writing a Benchmark | ||
|
||
Good benchmarks | ||
|
||
- are precise (i.e. running the test multiple times returns roughly the same result) | ||
- operate in a way that mimics real-world usage | ||
- use large, diverse, real-world data | ||
- are conceptually simple | ||
|
||
Benchmarks are implemented as a function that returns an instance of `Evented`. | ||
|
||
```js | ||
runBenchmark(options: { accessToken: string; }): Evented | ||
``` | ||
|
||
The instance of `Evented` may fire any number of `log` and `error` events. The | ||
instance of `Evented` must fire exactly one `end` event. | ||
|
||
### `log` | ||
|
||
Fire the `log` event to report benchmark progress to the user. | ||
|
||
```js | ||
{ | ||
message: string; | ||
color: string = 'blue'; // name of a Mapbox base color https://mapbox.com/base/styling/color | ||
} | ||
``` | ||
|
||
If your benchmark has a notion of running multiple "samples", you might emit | ||
one `log` event per sample. | ||
|
||
```js | ||
benchmark.fire('log', { | ||
message: 'Finished sample ' + i + ' in ' + formatNumber(time) + ' ms' | ||
}); | ||
``` | ||
|
||
These events have no machine-semantic meaning. | ||
|
||
### `end` | ||
|
||
Fire the `end` event to indicate the benchmark has finished running and report | ||
its results. | ||
|
||
These events have both human-readable results (`message`) and machine-readable results (`score`). Smaller `score`s are "better." | ||
|
||
```js | ||
{ | ||
message: string; | ||
score: number; | ||
} | ||
``` | ||
|
||
```js | ||
benchmark.fire('end', { | ||
message: 'Average time is ' + formatNumber(averageTime)) + 'ms', | ||
score: averageTime | ||
}); | ||
``` | ||
|
||
### `error` | ||
|
||
Fire the `error` event to indicate the benchmark has encountered a fatal error. | ||
|
||
```js | ||
{ | ||
error: Error; | ||
} | ||
``` |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.