From 19d8f93d23281a7320986f71085a66bbed098745 Mon Sep 17 00:00:00 2001 From: Ajay Sabhaney Date: Tue, 18 May 2021 14:25:20 -0400 Subject: [PATCH] perf tests 2 --- tests/utils/perf.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/utils/perf.js diff --git a/tests/utils/perf.js b/tests/utils/perf.js new file mode 100644 index 0000000..51a2204 --- /dev/null +++ b/tests/utils/perf.js @@ -0,0 +1,40 @@ +import generateResponsiveObject from '../../src/utils/generateResponsiveObject' +import generateResponsiveStyles from '../../src/utils/generateResponsiveStyles' + +const numCycles = 500 +const numProps = 15 + +test('generateResponsiveObject Performance', () => { + const t0 = performance.now() + for (let i = 0; i < numCycles; i += 1) { + for (let j = 0; j < numProps; j += 1) { + generateResponsiveObject('500px[a-c] 600px[d] 900px[e] 1200px[f]') + } + } + + const t1 = performance.now() + console.log(t1 - t0) +}) + +test('generateResponsiveStyles Performance', () => { + const responsiveObject = { + fontFamily: { + a: 'Arial', + b: 'Helvetica' + }, + color: { + a: 'red', + c: 'blue' + } + } + + const t0 = performance.now() + for (let i = 0; i < numCycles; i += 1) { + for (let j = 0; j < numProps; j += 1) { + generateResponsiveStyles(responsiveObject) + } + } + + const t1 = performance.now() + console.log(t1 - t0) +})