Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 57d5db3

Browse files
committed
Make relevant benchmarks
[skip ci]
1 parent 0951be4 commit 57d5db3

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

benchmarks.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ var cssnext = require("./")
22
var t = require("microtime")
33
var assign = require("object-assign")
44

5-
var input = require("fs").readFileSync("./test/fixtures/cases/example.css")
5+
var input = require("fs").readFileSync("./test/fixtures/benchmarks.css", {encoding: "utf8"})
6+
7+
// make a 2MB input
8+
for(var i=0;i<=10;i++) {
9+
input += input
10+
}
11+
// check the real input
12+
// require("fs").writeFileSync("./test/fixtures/bench.css", input)
613

714
// test each features
815
var keys = Object.keys(cssnext.features)
@@ -12,11 +19,13 @@ keys.forEach(function(k) {
1219
allOff[k] = false
1320
})
1421

22+
console.log("Each features is tested on a 2MB input (>100 000 lines)\n")
23+
1524
keys.forEach(function(k) {
1625
var enable = assign({}, allOff)
1726
enable[k] = true
1827
var start = t.now()
19-
cssnext(input, {features: enable})
28+
var out = cssnext(input, {features: enable})
2029
var stop = t.now()
2130

2231
console.log(k + " takes " + ((stop - start) / 1000000) + "s") // , enable)

test/fixtures/benchmarks.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* custom properties */
2+
:root {
3+
--fontSize: 1rem;
4+
--mainColor: #12345678;
5+
--highlightColor: hwb(190, 35%, 20%);
6+
}
7+
8+
/* custom media queries */
9+
@custom-media --viewport-medium (width <= 50em);
10+
11+
/* some var() & calc() */
12+
body {
13+
color: var(--mainColor);
14+
15+
font-size: var(--fontSize);
16+
line-height: calc(var(--fontSize) * 1.5);
17+
padding: calc((var(--fontSize) / 2) + 1px);
18+
}
19+
20+
/* custom media query usage */
21+
@media (--viewport-medium) {
22+
body { font-size: calc(var(--fontSize) * 1.2); }
23+
/* no need for px here since browsers that supports media queries support rem already */
24+
}
25+
26+
/* custom selectors */
27+
@custom-selector --heading h1, h2, h3, h4, h5, h6;
28+
--heading { margin-top: 0 }
29+
30+
/* colors stuff */
31+
a {
32+
color: var(--highlightColor);
33+
transition: color 1s; /* autoprefixed ! */
34+
}
35+
a:hover { color: gray(255, 50%) }
36+
a:active { color: rebeccapurple }
37+
a:visited { color: color(red blackness(+20%)) }
38+
39+
/* font stuff */
40+
h2 {
41+
font-variant-caps: small-caps;
42+
}
43+
44+
table {
45+
font-variant-numeric: lining-nums;
46+
}
47+
48+
/* filters */
49+
.blur {
50+
filter: blur(4px);
51+
}
52+
.sepia {
53+
filter: sepia(.8);
54+
}

0 commit comments

Comments
 (0)