1 | 'use strict'
|
2 |
|
3 | const test = require('tap').test
|
4 | const guessInterval = require('../analysis/guess-interval.js')
|
5 | const generateProcessStat = require('./generate-process-stat.js')
|
6 |
|
7 | test('guess interval - expected data', function (t) {
|
8 | for (const noise of [0, 1, 5]) {
|
9 | const data = generateProcessStat({
|
10 | handles: [3, 3, 3, 3, 3, 13, 13, 13, 13, 13, 13, 13, 3, 3, 3]
|
11 | }, noise, 10)
|
12 |
|
13 | const interval = guessInterval(data)
|
14 | t.strictDeepEqual(interval, [5, 12])
|
15 | }
|
16 |
|
17 | t.end()
|
18 | })
|
19 |
|
20 | test('guess interval - trims 100 ms from left and right side', function (t) {
|
21 | for (const noise of [0, 1, 5]) {
|
22 | const data = generateProcessStat({
|
23 | handles: [
|
24 | 3, 3, 3, 3, 3,
|
25 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
26 | 13, 13, 13, 13, 13, 13, 13,
|
27 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
28 | 3, 3, 3
|
29 | ]
|
30 | }, noise)
|
31 |
|
32 | const interval = guessInterval(data)
|
33 | t.strictDeepEqual(interval, [14, 23])
|
34 | }
|
35 |
|
36 | t.end()
|
37 | })
|
38 |
|
39 | test('guess interval - overtrim is not possible', function (t) {
|
40 | for (const noise of [0, 1, 5]) {
|
41 | const data = generateProcessStat({
|
42 | handles: [3, 3, 3, 3, 3, 13, 13, 13, 3, 3, 3]
|
43 | }, noise)
|
44 |
|
45 | const interval = guessInterval(data)
|
46 | t.strictDeepEqual(interval, [7, 7])
|
47 | }
|
48 |
|
49 | t.end()
|
50 | })
|
51 |
|
52 | test('guess interval - missing left tail', function (t) {
|
53 | for (const noise of [0, 1, 5]) {
|
54 | const data = generateProcessStat({
|
55 | handles: [3, 3, 3, 3, 3, 13, 13, 13, 13, 13, 13, 13]
|
56 | }, noise, 10)
|
57 |
|
58 | const interval = guessInterval(data)
|
59 | t.strictDeepEqual(interval, [5, 12])
|
60 | }
|
61 |
|
62 | t.end()
|
63 | })
|
64 |
|
65 | test('guess interval - missing right tail', function (t) {
|
66 | for (const noise of [0, 1, 5]) {
|
67 | const data = generateProcessStat({
|
68 | handles: [13, 13, 13, 13, 13, 3, 3, 3, 3, 3, 3, 3]
|
69 | }, noise, 10)
|
70 |
|
71 | const interval = guessInterval(data)
|
72 | t.strictDeepEqual(interval, [0, 5])
|
73 | }
|
74 |
|
75 | t.end()
|
76 | })
|
77 |
|
78 | test('guess interval - flat data', function (t) {
|
79 | const data = generateProcessStat({
|
80 | handles: [3, 3, 3, 3, 3, 3, 3, 3]
|
81 | }, 0, 10)
|
82 |
|
83 | const interval = guessInterval(data)
|
84 | t.strictDeepEqual(interval, [0, 8])
|
85 |
|
86 | t.end()
|
87 | })
|