add benchmarks to checkout contain: strict

This commit is contained in:
Matthew Griffith 2019-07-07 20:50:26 -04:00
parent d2934dad5a
commit ac74e54f16
4 changed files with 185 additions and 6 deletions

View File

@ -6,11 +6,11 @@ async function benchPage(page) {
// await page.tracing.start({ path: 'trace.json' });
await page.goto('file://' + path.resolve('./tmp/run.html'))
await page.waitFor(1000);
await page.waitFor(5000);
// await page.tracing.stop();
const metrics = await client.send('Performance.getMetrics');
await page.evaluate(() => { window.elmStartAnim() })
await sleep(10000)
await sleep(5000)
await page.evaluate(() => { window.elmStopAnim() })
const frames = await page.evaluate(x => {
return Promise.resolve(window.metrics);

View File

@ -54,6 +54,10 @@ function regroupResults(results) {
}
var contain = [{ module: "Contain", group: "html", count: 1024, value: "viewHtml8192" }
, { module: "Contain", group: "contain", count: 128, value: "viewHtmlContain8192" }]
async function write_results(allResults) {
var resultsDir = "benchmarks/results"
if (!fs.existsSync(resultsDir)) {
@ -71,11 +75,12 @@ async function write_results(allResults) {
}
(async () => {
const browser = await puppeteer.launch();
var instances = [{ module: "Baseline", group: null, value: "bench" }
var instances = [
{ module: "Baseline", group: null, value: "bench" }
, { module: "ManyElements", group: "elmUI", count: 1024, value: "elmUI1024" }
, { module: "ManyElements", group: "elmUI", count: 128, value: "elmUI128" }
, { module: "ManyElements", group: "elmUI", count: 2048, value: "elmUI2048" }
@ -112,7 +117,6 @@ async function write_results(allResults) {
, { module: "ManyElements", group: "viewInline", count: 512, value: "viewInline512" }
, { module: "ManyElements", group: "viewInline", count: 64, value: "viewInline64" }
, { module: "ManyElements", group: "viewInline", count: 8192, value: "viewInline8192" }
]

View File

@ -9,6 +9,22 @@
<script>
${compiled_elm_code}
</script>
<style>
.box {
width: 400px;
height: 50px;
border: solid thick;
}
.pink {
background-color: pink;
}
.white {
background-color: white;
}
.contain {
contain: strict;
}
</style>
</head>
<body>

159
benchmarks/src/Contain.elm Normal file
View File

@ -0,0 +1,159 @@
module Contain exposing
( viewHtml8192
, viewHtmlContain8192
)
{-| -}
import Benchmark.Render
import Element exposing (..)
import Element.Background as Background
import Element.Font as Font
import Element.Keyed
import Html
import Html.Attributes
import Internal.Model as Internal
type alias Model =
{ index : Int
, numberOfElements : Int
, elements : List Int
}
type Msg
= Refresh
| Tick Float
viewHtml8192 : Benchmark.Render.Benchmark Model Msg
viewHtml8192 =
viewHtml "viewHtml8192" 8192
viewHtmlContain8192 : Benchmark.Render.Benchmark Model Msg
viewHtmlContain8192 =
viewHtmlContain "viewHtmlContain8192" 8192
white =
rgb 1 1 1
pink =
rgb255 240 0 245
{-| -}
viewHtml : String -> Int -> Benchmark.Render.Benchmark Model Msg
viewHtml name count =
{ name = name
, init =
{ index = 0
, numberOfElements = count
, elements = List.range 0 (count - 1)
}
, view =
\model ->
Html.div []
[ Html.div []
(List.map (viewHtmlElement model.index) model.elements)
]
, update =
\msg model ->
case msg of
Refresh ->
if model.index > model.numberOfElements then
{ model | index = 0 }
else
{ model | index = model.index + 1 }
Tick i ->
if model.index > model.numberOfElements then
{ model | index = 0 }
else
{ model | index = model.index + 1 }
, tick = Tick
, refresh = Refresh
}
viewHtmlElement selectedIndex index =
Html.div
[ Html.Attributes.class "box"
, Html.Attributes.class
(if selectedIndex == index then
"white"
else
"pink"
)
]
[ Html.div []
[ if selectedIndex == index then
Html.text "selected"
else
Html.text "Hello!"
]
]
{-| -}
viewHtmlContain : String -> Int -> Benchmark.Render.Benchmark Model Msg
viewHtmlContain name count =
{ name = name
, init =
{ index = 0
, numberOfElements = count
, elements = List.range 0 (count - 1)
}
, view =
\model ->
Html.div []
[ Html.div []
(List.map (viewHtmlElementContain model.index) model.elements)
]
, update =
\msg model ->
case msg of
Refresh ->
if model.index > model.numberOfElements then
{ model | index = 0 }
else
{ model | index = model.index + 1 }
Tick i ->
if model.index > model.numberOfElements then
{ model | index = 0 }
else
{ model | index = model.index + 1 }
, tick = Tick
, refresh = Refresh
}
viewHtmlElementContain selectedIndex index =
Html.div
[ Html.Attributes.class "box contain"
, Html.Attributes.class
(if selectedIndex == index then
"white"
else
"pink"
)
]
[ Html.div []
[ if selectedIndex == index then
Html.text "selected"
else
Html.text "Hello!"
]
]