Files
bun.sh/bench/snippets/color.mjs
Michael H b54137174b Bench updates (#15029)
Co-authored-by: RiskyMH <RiskyMH@users.noreply.github.com>
2024-11-08 23:15:24 -08:00

26 lines
580 B
JavaScript

import Color from "color";
import tinycolor from "tinycolor2";
import { bench, group, run } from "../runner.mjs";
const inputs = ["#f00", "rgb(255, 0, 0)", "rgba(255, 0, 0, 1)", "hsl(0, 100%, 50%)"];
for (const input of inputs) {
group(`${input}`, () => {
if (typeof Bun !== "undefined") {
bench(`Bun.color() (${input})`, () => {
Bun.color(input, "css");
});
}
bench(`color (${input})`, () => {
Color(input).hex();
});
bench(`'tinycolor2' (${input})`, () => {
tinycolor(input).toHexString();
});
});
}
await run();