Skip to content

Crayon 3.3.3

Latest
Compare
Choose a tag to compare
@Im-Beast Im-Beast released this 03 Dec 13:27
· 61 commits to main since this release

Improvements

  • Crayon now uses more efficient way to re-cache styles when colorSupport value changes
    • It makes caching a lot faster (>240x faster) – look benchmark on the bottom
    • This also reduces memory usage by ~33%
  • Updated benchmarks
  • Added test for checking whether changing colorSupport has effect on instance styles
  • color_support extension now uses new Deno.Command API

Caching speed benchmark

Code:

import { crayon as c332, colors, attributes } from "https://deno.land/x/[email protected]/mod.ts";
import { crayon as c333 } from "https://deno.land/x/[email protected]/mod.ts";

const styles = [...colors.keys(), ...attributes.keys()]

await Deno.bench({ name: "C 3.3.3", group: "a", baseline: true }, () => {
   for (let i = 0; i < 1000; ++i) {
   	const a = styles[~~(Math.random() * styles.length)];
   	const b = styles[~~(Math.random() * styles.length)];
   	const c = styles[~~(Math.random() * styles.length)];		
   	const d = styles[~~(Math.random() * styles.length)];
   
   	c333[a][b][c][d]("hi")
   }
});

await Deno.bench({ name: "C 3.3.2", group: "a" }, () => {
   for (let i = 0; i < 1000; ++i) {
   	const a = styles[~~(Math.random() * styles.length)];
   	const b = styles[~~(Math.random() * styles.length)];
   	const c = styles[~~(Math.random() * styles.length)];		
   	const d = styles[~~(Math.random() * styles.length)];
   
   	c332[a][b][c][d]("hi")
   }
});

Result on my machine:
image