Skip to content

Commit

Permalink
feat: Add string-width to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
PondWader committed Jul 2, 2024
1 parent e87f2a0 commit b7420ee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bench/string-width.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Bench} from 'tinybench';
import {getStringWidth} from '../dist/string-width.js';
import fastStringTruncatedWidth from 'fast-string-truncated-width';
import stringWidth from 'string-width';

const fastStringTruncatedWidthOptions = {limit: Infinity, ellipsis: ''};

Expand Down Expand Up @@ -32,14 +33,13 @@ for (const suite of suites) {

bench
.add('picospinner getStringWidth()', () => {
for (const suite of suites) {
getStringWidth(suite.input);
}
getStringWidth(suite.input);
})
.add('fast-string-truncated-width', () => {
for (const suite of suites) {
fastStringTruncatedWidth(suite.input, fastStringTruncatedWidthOptions, {}).width;
}
fastStringTruncatedWidth(suite.input, fastStringTruncatedWidthOptions, {}).width;
})
.add('string-width', () => {
stringWidth(suite.input).width;
});

console.log('Benchmark:', suite.name);
Expand Down

0 comments on commit b7420ee

Please sign in to comment.