-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathtrace.js
70 lines (60 loc) · 1.57 KB
/
trace.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// eslint-disable-next-line import/no-extraneous-dependencies
const DataPoint = require("data-point");
const mocks = require("./async-example.mocks");
// mock request calls
mocks();
const { Model, Request } = DataPoint;
const PersonRequest = Request("PersonRequest", {
url: "https://swapi.co/api/people/{value}/"
});
const PersonModel = Model("PersonModel", {
value: {
name: "$name",
birthYear: "$birth_year"
}
});
const options = {
trace: false // <-- set to true to enable tracing, a file will be created
};
const dataPoint = DataPoint.create();
dataPoint.transform([PersonRequest, PersonModel], 1, options).then(() => {
/*
a file with the name data-point-trace-<timestamp>.json will
be created.
File follows the structure of:
{
"id": "1",
"reducer": {
"type": "ReducerList",
"reducers": [...]
},
"hrtime": [
405103,
401185279
],
"timeStartNs": 405103401185279,
"durationNs": 1270129916,
"durationMs": 1.270129916,
"timelineStartNs": 0,
"timelineStartMs": 0,
"nestingLevel": 0,
"label": "ReducerList:1",
"children": [
{
"id": "2",
"reducer": { }
"hrtime": [
405155,
401185299
],
"timeStartNs": 405103401185279,
"durationNs": 1270129916,
"durationMs": 1.270129916,
"timelineStartNs": 0,
"timelineStartMs": 0,
"nestingLevel": 0,
"label": "ReducerList:1",
"children": [
.....
*/
});