Skip to content

Commit 2339974

Browse files
committed
test(): caching
1 parent a19e9a6 commit 2339974

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/intersect.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ describe('path-intersection', function() {
2121
expect(intersections).to.have.length(1);
2222
});
2323

24+
it('should cache paths to boost performance', function() {
25+
26+
const p1 = [ [ 'M', 0, 0 ], [ 'L', 200, 200 ] ];
27+
const p2 = 'M0,200L200,0';
28+
29+
// when
30+
performance.mark('a')
31+
intersect(p1, p2);
32+
const { duration: a } = performance.measure('not cached', 'a');
33+
performance.mark('b')
34+
intersect(p1, p2);
35+
const { duration: b } = performance.measure('cached', 'b');
36+
// then
37+
expect(b).to.lessThanOrEqual(a)
38+
});
39+
2440
it('parsePathCurve', function() {
2541

2642
// when

0 commit comments

Comments
 (0)