@jscad/vtree 2.0.13 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -2
- package/core/api-measurements.js +8 -12
- package/core/buildCachedGeometryFromTree.js +2 -4
- package/core/cacheWithInvalidation.js +2 -2
- package/core/findDisconnectedSubGraphs.js +3 -3
- package/core/generators/geometry-generator-cached-csg.js +11 -13
- package/core/geometry-generator-cached.js +17 -19
- package/core/index.js +5 -5
- package/core/modeling/index-old.js +2 -2
- package/core/modeling/operations/measurements/measureArea.js +2 -2
- package/core/modeling/operations/measurements/measureBounds.js +2 -2
- package/core/modeling/operations/measurements/measureVolume.js +2 -2
- package/core/modeling/primitives/arc.js +1 -1
- package/core/modeling/primitives/cuboid.js +2 -2
- package/core/modeling/primitives/cylinderElliptic.js +2 -2
- package/core/modeling/primitives/line.js +1 -1
- package/core/modeling/primitives/rectangle.js +1 -1
- package/core/objectUtils.js +3 -5
- package/package.json +6 -6
- package/prototyping/examples/basic-base.js +1 -3
- package/prototyping/examples/basic-vtree.js +2 -4
- package/prototyping/examples/caching-shape-measurements.js +3 -3
- package/prototyping/examples/caching-test-vanilla-changed.js +18 -21
- package/prototyping/examples/caching-test-vanilla-changed2.js +16 -19
- package/prototyping/examples/caching-test-vanilla.js +15 -19
- package/prototyping/examples/caching-test-vtree-changed.js +18 -21
- package/prototyping/examples/caching-test-vtree-changed2.js +16 -19
- package/prototyping/examples/caching-test-vtree.js +15 -19
- package/prototyping/examples/caching-test.js +8 -10
- package/prototyping/examples/complex-base.js +19 -26
- package/prototyping/examples/complex-vtree-changed.js +19 -26
- package/prototyping/examples/complex-vtree.js +18 -25
- package/prototyping/examples/logo-base.js +9 -11
- package/prototyping/examples/logo-vtree.js +9 -11
- package/prototyping/examples/shapes-array-base.js +1 -3
- package/prototyping/examples/shapes-array-nested-vtree.js +15 -13
- package/prototyping/examples/shapes-array-vtree.js +2 -4
- package/prototyping/examples/single-shape-vtree.js +1 -3
- package/prototyping/examples/transforms-vtree.js +6 -9
- package/prototyping/examples/union-base.js +1 -3
- package/prototyping/examples/union-vtree.js +1 -3
- package/prototyping/io/deserializeGeometryCache.js +1 -1
- package/prototyping/io/serializeGeometryCache.js +1 -1
- package/prototyping/runBenchmark.js +9 -9
- package/prototyping/runCompare.js +6 -6
- package/vtree-api.js +1 -1
- package/prototyping/io/convertToBlob.js +0 -13
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
const { cube, sphere } = require('@jscad/csg/api').primitives3d
|
|
2
|
-
const { union
|
|
3
|
-
const { translate
|
|
2
|
+
const { union } = require('@jscad/csg/api').booleanOps
|
|
3
|
+
const { translate } = require('@jscad/csg/api').transformations
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
11
|
-
}
|
|
5
|
+
const foo = () => [
|
|
6
|
+
cube(),
|
|
7
|
+
translate([13, 0, 0], cube()),
|
|
8
|
+
sphere({ fn: 128 })
|
|
9
|
+
]
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
22
|
-
}
|
|
11
|
+
const main = () => [
|
|
12
|
+
foo(),
|
|
13
|
+
cube(),
|
|
14
|
+
translate([13, 0, 0], cube()),
|
|
15
|
+
translate([0, 0, 2], sphere()),
|
|
16
|
+
union(cube(), sphere()),
|
|
17
|
+
sphere({ fn: 128 })
|
|
18
|
+
]
|
|
23
19
|
|
|
24
20
|
module.exports = main
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
const {
|
|
2
2
|
cube, sphere,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
union,
|
|
4
|
+
rotate, translate
|
|
5
5
|
} = require('../../core/index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
sphere({ fn: 128 })
|
|
24
|
-
]
|
|
25
|
-
}
|
|
7
|
+
const foo = () => [
|
|
8
|
+
cube(),
|
|
9
|
+
translate([13, 0, 0], cube()),
|
|
10
|
+
sphere({ fn: 128 })
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
const main = () => [
|
|
14
|
+
foo(),
|
|
15
|
+
cube(),
|
|
16
|
+
translate([13, 0, 0], cube()),
|
|
17
|
+
translate([0, 0, 2], sphere()),
|
|
18
|
+
union(cube(), sphere()),
|
|
19
|
+
translate([23, 0, 0], cube()),
|
|
20
|
+
rotate([13, 0, 0], cube()),
|
|
21
|
+
sphere({ fn: 128 })
|
|
22
|
+
]
|
|
26
23
|
|
|
27
24
|
module.exports = main
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
const {
|
|
2
2
|
cube, sphere,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
union,
|
|
4
|
+
rotate, translate
|
|
5
5
|
} = require('../../core/index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rotate([13, 0, 0], cube())
|
|
22
|
-
]
|
|
23
|
-
}
|
|
7
|
+
const foo = () => [
|
|
8
|
+
cube(),
|
|
9
|
+
translate([13, 0, 0], cube())
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
const main = () => [
|
|
13
|
+
foo(),
|
|
14
|
+
cube(),
|
|
15
|
+
translate([13, 0, 0], cube()),
|
|
16
|
+
translate([0, 0, 2], sphere()),
|
|
17
|
+
union(cube(), sphere()),
|
|
18
|
+
translate([23, 0, 0], cube()),
|
|
19
|
+
rotate([13, 0, 0], cube())
|
|
20
|
+
]
|
|
24
21
|
|
|
25
22
|
module.exports = main
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
const {
|
|
2
2
|
cube, sphere,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
union,
|
|
4
|
+
translate
|
|
5
5
|
} = require('../../core/index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
}
|
|
7
|
+
const foo = () => [
|
|
8
|
+
cube(),
|
|
9
|
+
translate([13, 0, 0], cube()),
|
|
10
|
+
sphere({ fn: 128 })
|
|
11
|
+
]
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]
|
|
24
|
-
}
|
|
13
|
+
const main = () => [
|
|
14
|
+
foo(),
|
|
15
|
+
cube(),
|
|
16
|
+
translate([13, 0, 0], cube()),
|
|
17
|
+
translate([0, 0, 2], sphere()),
|
|
18
|
+
union(cube(), sphere()),
|
|
19
|
+
sphere({ fn: 128 })
|
|
20
|
+
]
|
|
25
21
|
|
|
26
22
|
module.exports = main
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
const { cube, sphere,
|
|
1
|
+
// note that API is injected so it is independent of implementation ! (vanilla vs vtree)
|
|
2
|
+
const main = (api) => {
|
|
3
|
+
const { cube, sphere, union, translate } = api
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
11
|
-
}
|
|
5
|
+
const foo = () => [
|
|
6
|
+
cube(),
|
|
7
|
+
translate([13, 0, 0], cube()),
|
|
8
|
+
sphere({ fn: 128 })
|
|
9
|
+
]
|
|
12
10
|
|
|
13
11
|
return [
|
|
14
12
|
foo(),
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
const { cube, sphere } = require('@jscad/csg/api').primitives3d
|
|
2
|
-
const {
|
|
3
|
-
const { translate
|
|
2
|
+
const { difference } = require('@jscad/csg/api').booleanOps
|
|
3
|
+
const { translate } = require('@jscad/csg/api').transformations
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
]
|
|
11
|
-
}
|
|
5
|
+
const aCoolPart = () => [
|
|
6
|
+
cube({ name: 'c1' }),
|
|
7
|
+
translate([13, 0, 0], cube({ name: 's1' })),
|
|
8
|
+
translate([0, 0, 2], sphere({ name: 's2' }))
|
|
9
|
+
]
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
}
|
|
11
|
+
const anotherCoolPart = () => difference(
|
|
12
|
+
cube({ name: 'c2', size: 1, center: true }),
|
|
13
|
+
sphere({ name: 's3', r: 0.6, fn: 128 })
|
|
14
|
+
)
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
return { type: 'part', children: [cube(), sphere()] }
|
|
22
|
-
}
|
|
16
|
+
const wowPart = () => ({ type: 'part', children: [cube(), sphere()] })
|
|
23
17
|
|
|
24
|
-
const flatten = arr =>
|
|
18
|
+
const flatten = (arr) =>
|
|
25
19
|
arr.reduce(
|
|
26
20
|
(flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten),
|
|
27
21
|
[]
|
|
28
22
|
)
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
24
|
+
const main = () => flatten([
|
|
25
|
+
translate([0, 5, 0], aCoolPart()),
|
|
26
|
+
anotherCoolPart(),
|
|
27
|
+
anotherCoolPart(),
|
|
28
|
+
wowPart()
|
|
29
|
+
])
|
|
37
30
|
|
|
38
31
|
module.exports = main
|
|
@@ -1,40 +1,33 @@
|
|
|
1
1
|
const {
|
|
2
2
|
cube, sphere,
|
|
3
|
-
difference,
|
|
4
|
-
|
|
3
|
+
difference,
|
|
4
|
+
translate
|
|
5
5
|
} = require('../../core/index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
}
|
|
7
|
+
const aCoolPart = () => [
|
|
8
|
+
cube({ name: 'c1' }),
|
|
9
|
+
translate([13, 0, 0], cube({ name: 's1' })),
|
|
10
|
+
translate([0, 0, 2], sphere({ name: 's2' }))
|
|
11
|
+
]
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
20
|
-
}
|
|
13
|
+
const anotherCoolPart = () => difference(
|
|
14
|
+
cube({ name: 'c2', size: 1, center: true }),
|
|
15
|
+
sphere({ name: 's3', r: 0.6, fn: 128 })
|
|
16
|
+
)
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
return { type: 'part', children: [cube(), sphere()] }
|
|
24
|
-
}
|
|
18
|
+
const wowPart = () => ({ type: 'part', children: [cube(), sphere()] })
|
|
25
19
|
|
|
26
|
-
const flatten = arr =>
|
|
20
|
+
const flatten = (arr) =>
|
|
27
21
|
arr.reduce(
|
|
28
22
|
(flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten),
|
|
29
23
|
[]
|
|
30
24
|
)
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
26
|
+
const main = () => flatten([
|
|
27
|
+
translate([0, 5, 0], aCoolPart()),
|
|
28
|
+
anotherCoolPart(),
|
|
29
|
+
anotherCoolPart(),
|
|
30
|
+
wowPart()
|
|
31
|
+
])
|
|
39
32
|
|
|
40
33
|
module.exports = main
|
|
@@ -1,39 +1,32 @@
|
|
|
1
1
|
const {
|
|
2
2
|
cube, sphere,
|
|
3
|
-
difference,
|
|
4
|
-
|
|
3
|
+
difference,
|
|
4
|
+
translate
|
|
5
5
|
} = require('../../core/index')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
}
|
|
7
|
+
const aCoolPart = () => [
|
|
8
|
+
cube({ name: 'c1' }),
|
|
9
|
+
translate([3, 0, 0], cube({ name: 's1' })),
|
|
10
|
+
translate([0, 0, 2], sphere({ name: 's2' }))
|
|
11
|
+
]
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
20
|
-
}
|
|
13
|
+
const anotherCoolPart = () => difference(
|
|
14
|
+
cube({ name: 'c2', size: 1, center: true }),
|
|
15
|
+
sphere({ name: 's3', r: 0.6, fn: 128 })
|
|
16
|
+
)
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
return { type: 'part', children: [cube(), sphere()] }
|
|
24
|
-
}
|
|
18
|
+
const wowPart = () => ({ type: 'part', children: [cube(), sphere()] })
|
|
25
19
|
|
|
26
|
-
const flatten = arr =>
|
|
20
|
+
const flatten = (arr) =>
|
|
27
21
|
arr.reduce(
|
|
28
22
|
(flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten),
|
|
29
23
|
[]
|
|
30
24
|
)
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
26
|
+
const main = () => flatten([
|
|
27
|
+
translate([0, 5, 0], aCoolPart()),
|
|
28
|
+
anotherCoolPart(),
|
|
29
|
+
wowPart()
|
|
30
|
+
])
|
|
38
31
|
|
|
39
32
|
module.exports = main
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
const { cube, sphere } = require('@jscad/csg/api').primitives3d
|
|
2
2
|
const { union, difference, intersection } = require('@jscad/csg/api').booleanOps
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cube({ size: 2.1, center: true })
|
|
13
|
-
)
|
|
4
|
+
const main = () => union(
|
|
5
|
+
difference(
|
|
6
|
+
cube({ size: 3, center: true }),
|
|
7
|
+
sphere({ r: 2, center: true })
|
|
8
|
+
),
|
|
9
|
+
intersection(
|
|
10
|
+
sphere({ r: 1.3, center: true }),
|
|
11
|
+
cube({ size: 2.1, center: true })
|
|
14
12
|
)
|
|
15
|
-
|
|
13
|
+
)
|
|
16
14
|
|
|
17
15
|
module.exports = main
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
const { cube, sphere, difference, intersection, union } = require('../../core/index')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cube({ size: 2.1, center: true })
|
|
12
|
-
)
|
|
3
|
+
const main = () => union(
|
|
4
|
+
difference(
|
|
5
|
+
cube({ size: 3, center: true }),
|
|
6
|
+
sphere({ r: 2, center: true })
|
|
7
|
+
),
|
|
8
|
+
intersection(
|
|
9
|
+
sphere({ r: 1.3, center: true }),
|
|
10
|
+
cube({ size: 2.1, center: true })
|
|
13
11
|
)
|
|
14
|
-
|
|
12
|
+
)
|
|
15
13
|
|
|
16
14
|
module.exports = main
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
const { cube, sphere,
|
|
1
|
+
const { cube, sphere, union } = require('../../core/index')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
const aCoolPart = () => [
|
|
4
|
+
cube({ name: 'c1' }),
|
|
5
|
+
cube({ name: 's1' }),
|
|
6
|
+
sphere({ name: 's2' })
|
|
7
|
+
]
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
return union(cube({ name: 'c2' }), sphere({ name: 's3' }))
|
|
9
|
-
}
|
|
9
|
+
const anotherCoolPart = () => union(cube({ name: 'c2' }), sphere({ name: 's3' }))
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
return { type: 'part', children: [cube(), sphere()] }
|
|
13
|
-
}
|
|
11
|
+
const wowPart = () => ({ type: 'part', children: [cube(), sphere()] })
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
const main = () => [
|
|
14
|
+
cube({ name: 'c3' }),
|
|
15
|
+
sphere({ name: 's4' }),
|
|
16
|
+
aCoolPart(),
|
|
17
|
+
anotherCoolPart(),
|
|
18
|
+
wowPart()
|
|
19
|
+
]
|
|
18
20
|
|
|
19
21
|
module.exports = main
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
const {
|
|
2
|
-
cube,
|
|
3
|
-
difference, intersection, union,
|
|
2
|
+
cube,
|
|
4
3
|
scale, rotate, translate
|
|
5
4
|
} = require('../../core/index')
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
}
|
|
6
|
+
const main = () => [
|
|
7
|
+
translate([0, 5, 0], cube({ size: 10 })),
|
|
8
|
+
scale([1, 2, 1], rotate([0, 10, 0], cube({ size: 10 }))),
|
|
9
|
+
cube({ size: 10 })
|
|
10
|
+
]
|
|
14
11
|
|
|
15
12
|
module.exports = main
|
|
@@ -2,7 +2,7 @@ const serialize = require('serialize-to-js')
|
|
|
2
2
|
|
|
3
3
|
const deserializeGeometryCache = (cache) => {
|
|
4
4
|
const data = {}
|
|
5
|
-
Object.keys(cache).map(
|
|
5
|
+
Object.keys(cache).map((key) => {
|
|
6
6
|
data[key] = cache[key]// .toCompactBinary()
|
|
7
7
|
})
|
|
8
8
|
/* results.forEach(function (result) {
|
|
@@ -8,7 +8,7 @@ const serializeGeometryCache = (cache) => {
|
|
|
8
8
|
fs.mkdirSync(cachePath)
|
|
9
9
|
}
|
|
10
10
|
const data = {}
|
|
11
|
-
Object.keys(cache).map(
|
|
11
|
+
Object.keys(cache).map((key) => {
|
|
12
12
|
data[key] = cache[key]// .toCompactBinary()
|
|
13
13
|
})
|
|
14
14
|
/* results.forEach(function (result) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// const decache = require('decache')
|
|
2
2
|
const child_process = require('child_process')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const runBenchMark = (runFn, name, runs = 10) => {
|
|
5
5
|
console.log('running benchmarks for ' + name + ' ' + runs + ' times')
|
|
6
6
|
|
|
7
7
|
// first verify they all have the same output
|
|
@@ -17,7 +17,7 @@ function runBenchMark (runFn, name, runs = 10) {
|
|
|
17
17
|
runPass(runFn, runs, name)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const spawnBenchMark = (path, runs = 100) => {
|
|
21
21
|
const usage = require('usage')
|
|
22
22
|
const cpuNumbers = []
|
|
23
23
|
const memNumbers = []
|
|
@@ -25,8 +25,8 @@ function spawnBenchMark (path, runs = 100) {
|
|
|
25
25
|
const process = child_process.spawn('node', [path, runs])
|
|
26
26
|
|
|
27
27
|
const pid = process.pid // you can use any valid PID instead
|
|
28
|
-
const measureInterval = setInterval(
|
|
29
|
-
usage.lookup(pid,
|
|
28
|
+
const measureInterval = setInterval(() => {
|
|
29
|
+
usage.lookup(pid, (err, result) => {
|
|
30
30
|
if (err) {
|
|
31
31
|
console.log('error?', err)
|
|
32
32
|
}
|
|
@@ -37,15 +37,15 @@ function spawnBenchMark (path, runs = 100) {
|
|
|
37
37
|
})
|
|
38
38
|
}, 1000)
|
|
39
39
|
|
|
40
|
-
process.stdout.on('data',
|
|
40
|
+
process.stdout.on('data', (data) => {
|
|
41
41
|
console.log('' + data)
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
process.stderr.on('data',
|
|
44
|
+
process.stderr.on('data', (data) => {
|
|
45
45
|
console.log('' + data)
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
process.on('close',
|
|
48
|
+
process.on('close', (code) => {
|
|
49
49
|
// console.log('Child process is exiting with exit code: ' + code)
|
|
50
50
|
clearInterval(measureInterval)
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ const runPass = (runFn, runs, name) => {
|
|
|
62
62
|
let start
|
|
63
63
|
|
|
64
64
|
const numbers = []
|
|
65
|
-
for (
|
|
65
|
+
for (let i = 0; i < runs; i++) {
|
|
66
66
|
// decache(moduleName)
|
|
67
67
|
|
|
68
68
|
start = process.hrtime()
|
|
@@ -76,7 +76,7 @@ const runPass = (runFn, runs, name) => {
|
|
|
76
76
|
// console.log(name + process.hrtime(start)[0] + ' s, ' + elapsed.toFixed(precision) + ' ms - ')
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
const median = sequence => {
|
|
79
|
+
const median = (sequence) => {
|
|
80
80
|
sequence.sort() // note that direction doesn't matter
|
|
81
81
|
return sequence[Math.ceil(sequence.length / 2)]
|
|
82
82
|
}
|