UNPKG

3.22 kBJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const analyseHandles = require('../analysis/analyse-handles.js')
5const generateProcessStat = require('./generate-process-stat.js')
6
7test('analyse handles - no data', function (t) {
8 const goodHandles = generateProcessStat({
9 handles: [100]
10 }, 0)
11 t.strictEqual(analyseHandles({}, goodHandles, []), 'data')
12
13 t.end()
14})
15
16test('analyse handles - flat', function (t) {
17 const goodHandles = generateProcessStat({
18 handles: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
19 }, 0)
20 t.strictEqual(analyseHandles({}, goodHandles, []), 'none')
21
22 t.end()
23})
24
25test('analyse handles - symetric data', function (t) {
26 for (const noise of [0, 10, 30]) {
27 const goodHandles = generateProcessStat({
28 handles: [100, 100, 120, 90, 110, 100, 80, 110, 90, 110]
29 }, noise)
30 t.strictEqual(analyseHandles({}, goodHandles, []), 'none')
31 }
32 t.end()
33})
34
35test('analyse handles - sawtooth data', function (t) {
36 for (const noise of [0, 10, 30]) {
37 const badHandles = generateProcessStat({
38 handles: [
39 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
40 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
41 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
42 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
43 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
44 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100,
45 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 100
46 ]
47 }, noise)
48 t.strictEqual(analyseHandles({}, badHandles, []), 'performance')
49 }
50 t.end()
51})
52
53test('analyse handles - increasing data', function (t) {
54 for (const noise of [0, 10, 30]) {
55 const badHandles = generateProcessStat({
56 handles: [
57 100, 120, 140, 160, 180, 200, 200, 200, 200, 200,
58 200, 220, 240, 260, 280, 300, 300, 300, 300, 300,
59 300, 320, 340, 360, 380, 400, 400, 400, 400, 400,
60 400, 420, 440, 460, 480, 500, 500, 500, 500, 500,
61 500, 520, 540, 560, 580, 600, 600, 600, 600, 600,
62 600, 620, 640, 660, 680, 700, 700, 700, 700, 700,
63 700, 720, 740, 760, 780, 800, 800, 800, 800, 800,
64 800, 820, 840, 860, 880, 900, 900, 900, 900, 900,
65 900, 920, 940, 960, 980, 999, 999, 999, 999, 999,
66 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
67 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
68 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
69 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
70 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
71 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
72 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
73 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
74 999, 999, 999, 999, 999, 999, 999, 999, 999, 999
75 ]
76 }, noise)
77 t.strictEqual(analyseHandles({}, badHandles, []), 'performance')
78 }
79 t.end()
80})
81
82test('analyse handles - almost constant', function (t) {
83 const goodHandles = generateProcessStat({
84 handles: [
85 100, 100, 100, 100, 100, 100, 100, 100, 100,
86 101, 101, 101, 101, 101, 101, 101, 101, 101]
87 }, 0)
88 t.strictEqual(analyseHandles({}, goodHandles, []), 'none')
89
90 t.end()
91})