UNPKG

949 BJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const analyseDelay = require('../analysis/analyse-delay.js')
5const generateProcessStat = require('./generate-process-stat.js')
6
7test('analyse delay - to high', function (t) {
8 for (const noise of [0, 1, 10]) {
9 const goodDelay = generateProcessStat({
10 delay: [1, 2, 1, 1, 2, 2, 3, 1]
11 }, noise)
12 t.strictEqual(analyseDelay({}, goodDelay, []), 'none')
13
14 const badDelay = generateProcessStat({
15 delay: [10, 8, 6, 10, 15, 10, 4]
16 }, noise)
17 t.strictEqual(analyseDelay({}, badDelay, []), 'performance')
18 }
19
20 t.end()
21})
22
23test('analyse delay - spikes', function (t) {
24 const goodDelay = generateProcessStat({
25 delay: [1, 2, 1, 20, 2, 2, 3, 1]
26 }, 1)
27 t.strictEqual(analyseDelay({}, goodDelay, []), 'none')
28
29 const badDelay = generateProcessStat({
30 delay: [1, 2, 1, 110, 2, 2, 3, 1]
31 }, 1)
32 t.strictEqual(analyseDelay({}, badDelay, []), 'performance')
33
34 t.end()
35})