惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
I
InfoQ
月光博客
月光博客
量子位
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
D
DataBreaches.Net
宝玉的分享
宝玉的分享
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理

时间的朋友

Windows 命令行密码重置 Anaconda安装 typescript 注解解读1 Konvajs Shape加载自定义图片 sshpass 使用 why-is-node-running webgl笔记 SharedArrayBuffer is not defined blender 常用快捷键 | 时间的朋友 vue -- v3.4commit提交记录2 vue2 升级vue3报错问题整理 着色器 expressjs 源码 hyper-V arch linux 网络配置 element input数字格式化 three 拼接货架 WebAudio笔记 Windows nginx重启bat脚本 vue -- v3.4commit提交记录 URI malformed vue3 -- Class 对象在组件中使用范例 | 时间的朋友 ruby 安装和升级 element-plus 老版本cascader使用卡死问题 vue3 内置Transition组件 | 时间的朋友 前端memo的实现 | 时间的朋友 Vue -- vue-class-component源码 | 时间的朋友 linux 优化脚本 typescript 装饰器 | 时间的朋友 microbundle 源码 | 时间的朋友 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc
Benchmark.js 使用 | 时间的朋友
2023-03-18 · via 时间的朋友

Published: · LastMod: March 19, 2023 · 166 words

Benchmark.js 🔗

安装 🔗

npm install benchmark

使用 🔗

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var Benchmark = require("benchmark");

var suite = Benchmark.Suite("string");

suite
	.add("String#regexp", function () {
		/o/.test("Hello World!");
	})
	.add("String#indexOf", function () {
		"Hello World!".indexOf("o") > -1;
	})
	.add("String#lastIndexOf", function () {
		"Hello World!".lastIndexOf("o") > -1;
	})
	.add("String#startsWith", function () {
		"Hello World!".startsWith("Hello");
	})
	.add("String#endsWith", function () {
		"Hello World!".endsWith("Hello");
	})
	.on("cycle", function (event) {
		console.log(String(event.target));
	})
	.run({ async: true });

输出 🔗

1
2
3
4
5
String#regexp x 27,318,384 ops/sec ±1.33% (91 runs sampled)
String#indexOf x 520,992,635 ops/sec ±1.40% (81 runs sampled)
String#lastIndexOf x 19,399,469 ops/sec ±0.22% (92 runs sampled)
String#startsWith x 38,492,366 ops/sec ±0.26% (93 runs sampled)
String#endsWith x 47,208,542 ops/sec ±0.21% (93 runs sampled)