1 | import Piscina from '..';
|
---|
2 | import { test } from 'tap';
|
---|
3 | import { resolve } from 'path';
|
---|
4 |
|
---|
5 | test('pool will maintain run and wait time histograms', async ({ equal, ok }) => {
|
---|
6 | const pool = new Piscina({
|
---|
7 | filename: resolve(__dirname, 'fixtures/eval.js')
|
---|
8 | });
|
---|
9 |
|
---|
10 | const tasks = [];
|
---|
11 | for (let n = 0; n < 10; n++) {
|
---|
12 | tasks.push(pool.runTask('42'));
|
---|
13 | }
|
---|
14 | await Promise.all(tasks);
|
---|
15 |
|
---|
16 | const waitTime = pool.waitTime as any;
|
---|
17 | ok(waitTime);
|
---|
18 | equal(typeof waitTime.average, 'number');
|
---|
19 | equal(typeof waitTime.mean, 'number');
|
---|
20 | equal(typeof waitTime.stddev, 'number');
|
---|
21 | equal(typeof waitTime.min, 'number');
|
---|
22 | equal(typeof waitTime.max, 'number');
|
---|
23 |
|
---|
24 | const runTime = pool.runTime as any;
|
---|
25 | ok(runTime);
|
---|
26 | equal(typeof runTime.average, 'number');
|
---|
27 | equal(typeof runTime.mean, 'number');
|
---|
28 | equal(typeof runTime.stddev, 'number');
|
---|
29 | equal(typeof runTime.min, 'number');
|
---|
30 | equal(typeof runTime.max, 'number');
|
---|
31 | });
|
---|