@as-tral/cli

中文文档
3.0.2发布于 2024/01/11ES Module近 30 天下载 2416

logo

中文使用文档
文档目录3 节
  1. 快速启动
  2. 诉讼 (专题请求)
  3. 旗帜

logo


为AssemblyScript提供最低限度、最先进的基准;As-tral是面向统计的Rust基准图书馆的一端 标准.

快速启动

在现有的 AssemblyScript 项目, 安装为三角形.

npm i -D @as-tral/cli

下一个,创建一个 __benches__ 在您的文件夹中 assembly 目录。 添加名为的文件 as-tral.d.ts 在那边.

assembly/
└── __benches__/
    └── as-tral.d.ts

单位 as-tral.d.ts复制和粘贴

/// <reference types="@as-tral/cli/as-tral" />

粘贴任何文件 .ts 扩展 __benches__你甚至可以拥有多个.

assembly/
└── __benches__/
    ├── as-tral.d.ts
    └── my-benchmark.ts

您的基准将活在这个文件中 。 让我们建立一个实例基准.

// to ensure accurate benchmarks, we must make sure that binaryen doesn't do any sneaky
// optimizations on our input without us knowing. Thus, we must use `blackbox`.
const input = blackbox("The quick brown fox jumped over the lazy dog.".repeat(10));

// our string here must be a compile time constant.
// open an issue if you'd like to see this constraint lifted.
bench("string split", () => {
    // this function body will be run many times.
    // we must make sure our compiler won't throw away the computation,
    // so we use `blackbox` here again.
    blackbox(input.split(" "));
});

瞷иǐ.

rom@i9-cabin:~/demo$ npx astral
Compiling assembly/__benches__/hello.ts

Benchmarking string split: Warming up for 3000ms
Benchmarking string split: Collecting 100 samples in estimated 5018.6ms (1.2M iterations)
Benchmarking string split: Analyzing
string split            time: [3770.9ns 3775ns 3778.9ns]
Found 4 outliers among 100 measurements (4%)
  3 (3%) low mild
  1 (1%) high mild

相当快!

诉讼 (专题请求)

需要额外输出吗?

Relative to bubble sort
insertion sort          delta: [-39.704% -38.188% -36.807%] (p = 0.00 < 0.05)
selection sort          delta: [-70.733% -70.102% -69.483%] (p = 0.00 < 0.05)
merge sort              delta: [-81.935% -81.587% -81.226%] (p = 0.00 < 0.05)
quick sort              delta: [-91.517% -91.358% -91.201%] (p = 0.00 < 0.05)

简单地分组您使用的基准 suite。 。 。 .

suite("sort", () => {
    bench("bubble sort", () => {
        bubbleSort();
    });

    bench("insertion sort", () => {
        insertionSort();
    });

    // ...
});

旗帜

CLI之前会解释所有的旗帜 -- 作为 AssemblyScript 编译器选项. 例如,为了使无害环境管理具有约束力,

npx astral --bindings esm

如果你还想要保存到某个基线,

npx astral --bindings esm -- --save-baseline mybaseline

从某个基准装入类似.

npx astral --bindings esm -- --save-baseline mybaseline --baseline myotherbaseline

版本与发布记录

@as-tral/cli 共发布 13 个版本,首次发布于 2022/05/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.2latest2024/01/112 年前
3.0.12024/01/102 年前
3.0.02024/01/092 年前
2.0.12023/08/143 年前
2.0.02022/12/123 年前
1.2.02022/09/194 年前

关于 @as-tral/cli 的常见问题

如何安装 @as-tral/cli?

在项目目录运行 npm install @as-tral/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 astral,可以用 npx astral 直接运行。

@as-tral/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/as-tral__cli 是否存在。

@as-tral/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@as-tral/cli 可以商用吗?

@as-tral/cli 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@as-tral/cli 的下载量有多少?

根据 npm 官方下载统计,@as-tral/cli 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,416 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@as-tral/cli 还在维护吗?

最新版本 3.0.2 发布于 2024/01/11(2 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。