Skip to content

Commit 8869ef5

Browse files
committed
Update benchmarks
1 parent fe05e36 commit 8869ef5

File tree

2 files changed

+2
-160
lines changed

2 files changed

+2
-160
lines changed

benchmark.js

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,6 @@ once
625625
.add("1 call", function() {
626626
process(styles, portrait, Platform);
627627
})
628-
.add("1 call (return early)", function() {
629-
process(stylesWithoutMediaQueries, portrait, Platform);
630-
})
631628
.on("cycle", function(event) {
632629
console.log(String(event.target));
633630
})
@@ -641,13 +638,6 @@ onceRequire
641638
.add("1 call (require)", function() {
642639
require("./dist/perf-tests/current").process(styles, portrait, Platform);
643640
})
644-
.add("1 call (require, return early)", function() {
645-
require("./dist/perf-tests/current").process(
646-
stylesWithoutMediaQueries,
647-
portrait,
648-
Platform
649-
);
650-
})
651641
.on("cycle", function(event) {
652642
console.log(String(event.target));
653643
})
@@ -664,12 +654,6 @@ fourTimes
664654
process(styles, portrait, Platform);
665655
process(styles, landscape, Platform);
666656
})
667-
.add("4 calls (orientation change, return early)", function() {
668-
process(stylesWithoutMediaQueries, portrait, Platform);
669-
process(stylesWithoutMediaQueries, landscape, Platform);
670-
process(stylesWithoutMediaQueries, portrait, Platform);
671-
process(stylesWithoutMediaQueries, landscape, Platform);
672-
})
673657
.on("cycle", function(event) {
674658
console.log(String(event.target));
675659
})
@@ -686,28 +670,6 @@ fourTimesRequire
686670
require("./dist/perf-tests/current").process(styles, portrait, Platform);
687671
require("./dist/perf-tests/current").process(styles, landscape, Platform);
688672
})
689-
.add("4 calls (orientation change, require, return early)", function() {
690-
require("./dist/perf-tests/current").process(
691-
stylesWithoutMediaQueries,
692-
portrait,
693-
Platform
694-
);
695-
require("./dist/perf-tests/current").process(
696-
stylesWithoutMediaQueries,
697-
landscape,
698-
Platform
699-
);
700-
require("./dist/perf-tests/current").process(
701-
stylesWithoutMediaQueries,
702-
portrait,
703-
Platform
704-
);
705-
require("./dist/perf-tests/current").process(
706-
stylesWithoutMediaQueries,
707-
landscape,
708-
Platform
709-
);
710-
})
711673
.on("cycle", function(event) {
712674
console.log(String(event.target));
713675
})
@@ -728,16 +690,6 @@ eightTimesTheSame
728690
process(styles, portrait, Platform);
729691
process(styles, portrait, Platform);
730692
})
731-
.add("8 calls (the same parameters, return early)", function() {
732-
process(stylesWithoutMediaQueries, portrait, Platform);
733-
process(stylesWithoutMediaQueries, portrait, Platform);
734-
process(stylesWithoutMediaQueries, portrait, Platform);
735-
process(stylesWithoutMediaQueries, portrait, Platform);
736-
process(stylesWithoutMediaQueries, portrait, Platform);
737-
process(stylesWithoutMediaQueries, portrait, Platform);
738-
process(stylesWithoutMediaQueries, portrait, Platform);
739-
process(stylesWithoutMediaQueries, portrait, Platform);
740-
})
741693
.on("cycle", function(event) {
742694
console.log(String(event.target));
743695
})
@@ -758,48 +710,6 @@ eightTimesTheSameRequire
758710
require("./dist/perf-tests/current").process(styles, portrait, Platform);
759711
require("./dist/perf-tests/current").process(styles, portrait, Platform);
760712
})
761-
.add("8 calls (the same parameters, require, return early)", function() {
762-
require("./dist/perf-tests/current").process(
763-
stylesWithoutMediaQueries,
764-
portrait,
765-
Platform
766-
);
767-
require("./dist/perf-tests/current").process(
768-
stylesWithoutMediaQueries,
769-
portrait,
770-
Platform
771-
);
772-
require("./dist/perf-tests/current").process(
773-
stylesWithoutMediaQueries,
774-
portrait,
775-
Platform
776-
);
777-
require("./dist/perf-tests/current").process(
778-
stylesWithoutMediaQueries,
779-
portrait,
780-
Platform
781-
);
782-
require("./dist/perf-tests/current").process(
783-
stylesWithoutMediaQueries,
784-
portrait,
785-
Platform
786-
);
787-
require("./dist/perf-tests/current").process(
788-
stylesWithoutMediaQueries,
789-
portrait,
790-
Platform
791-
);
792-
require("./dist/perf-tests/current").process(
793-
stylesWithoutMediaQueries,
794-
portrait,
795-
Platform
796-
);
797-
require("./dist/perf-tests/current").process(
798-
stylesWithoutMediaQueries,
799-
portrait,
800-
Platform
801-
);
802-
})
803713
.on("cycle", function(event) {
804714
console.log(String(event.target));
805715
})
@@ -820,16 +730,6 @@ eightTimes
820730
process(styles, portrait, Platform);
821731
process(styles, landscape, Platform);
822732
})
823-
.add("8 calls (orientation change, return early)", function() {
824-
process(stylesWithoutMediaQueries, portrait, Platform);
825-
process(stylesWithoutMediaQueries, landscape, Platform);
826-
process(stylesWithoutMediaQueries, portrait, Platform);
827-
process(stylesWithoutMediaQueries, landscape, Platform);
828-
process(stylesWithoutMediaQueries, portrait, Platform);
829-
process(stylesWithoutMediaQueries, landscape, Platform);
830-
process(stylesWithoutMediaQueries, portrait, Platform);
831-
process(stylesWithoutMediaQueries, landscape, Platform);
832-
})
833733
.on("cycle", function(event) {
834734
console.log(String(event.target));
835735
})
@@ -850,48 +750,6 @@ eightTimesRequire
850750
require("./dist/perf-tests/current").process(styles, portrait, Platform);
851751
require("./dist/perf-tests/current").process(styles, landscape, Platform);
852752
})
853-
.add("8 calls (orientation change, require, return early)", function() {
854-
require("./dist/perf-tests/current").process(
855-
stylesWithoutMediaQueries,
856-
portrait,
857-
Platform
858-
);
859-
require("./dist/perf-tests/current").process(
860-
stylesWithoutMediaQueries,
861-
landscape,
862-
Platform
863-
);
864-
require("./dist/perf-tests/current").process(
865-
stylesWithoutMediaQueries,
866-
portrait,
867-
Platform
868-
);
869-
require("./dist/perf-tests/current").process(
870-
stylesWithoutMediaQueries,
871-
landscape,
872-
Platform
873-
);
874-
require("./dist/perf-tests/current").process(
875-
stylesWithoutMediaQueries,
876-
portrait,
877-
Platform
878-
);
879-
require("./dist/perf-tests/current").process(
880-
stylesWithoutMediaQueries,
881-
landscape,
882-
Platform
883-
);
884-
require("./dist/perf-tests/current").process(
885-
stylesWithoutMediaQueries,
886-
portrait,
887-
Platform
888-
);
889-
require("./dist/perf-tests/current").process(
890-
stylesWithoutMediaQueries,
891-
landscape,
892-
Platform
893-
);
894-
})
895753
.on("cycle", function(event) {
896754
console.log(String(event.target));
897755
})

src/perf-tests/current.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ function isMediaQuery(str) {
88
return typeof str === "string" && str.indexOf(PREFIX) === 0;
99
}
1010

11-
function omit(obj, omitKey) {
12-
return Object.keys(obj).reduce((result, key) => {
13-
if (key !== omitKey) {
14-
result[key] = obj[key];
15-
}
16-
return result;
17-
}, {});
18-
}
19-
2011
function filterMq(obj) {
2112
return Object.keys(obj).filter(key => isMediaQuery(key));
2213
}
@@ -32,20 +23,13 @@ function filterNonMq(obj) {
3223

3324
const mFilterMq = memoize(filterMq);
3425
const mFilterNonMq = memoize(filterNonMq);
35-
const mOmit = memoize(omit);
3626

3727
export function process(obj, matchObject, Platform) {
38-
const hasParsedMQs = "__mediaQueries" in obj;
39-
40-
if (!hasParsedMQs) {
41-
return obj;
42-
}
43-
4428
const mqKeys = mFilterMq(obj);
4529
let res = mFilterNonMq(obj);
4630

4731
mqKeys.forEach(key => {
48-
if (/^@media\s+(ios|android)/i.test(key)) {
32+
if (/^@media\s+(not\s+)?(ios|android)/i.test(key)) {
4933
matchObject.type = Platform.OS;
5034
} else {
5135
matchObject.type = "screen";
@@ -57,5 +41,5 @@ export function process(obj, matchObject, Platform) {
5741
}
5842
});
5943

60-
return mOmit(res, "__mediaQueries");
44+
return res;
6145
}

0 commit comments

Comments
 (0)