Map versus consts (v8)

Revision 8 of this benchmark created on


Preparation HTML

<script type="module">
import { css } from "https://unpkg.com/@microsoft/fast-element@2.0.0/dist/fast-element.min.js"

globalThis.css = css;

const CustomStatesSetSupported = CSS.supports('selector(:state(g))');

const statesMap = new Map();

globalThis.stateSelector = function stateSelector(state) {
  return (statesMap.get(state) ??
    statesMap
      .set(state, CustomStatesSetSupported ? css.partial`:state(${state})` : css.partial`[state--${state}]`)
      .get(state));
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
StateSelector
stateSelector('foo');
ready
CSS Partial
css.partial`:is(:state(foo), [state--foo])`;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.