找出你的服务器在 Skript 上实际花费了多少时间
skTrace 是一款专为 Skript 构建的性能分析器。它在服务器运行时测量触发器、函数、事件、循环以及变量写入的情况,然后将其转换为可在浏览器中打开或通过链接分享的交互式 HTML 报告。
执行 /sktrace start,让卡顿发生,然后执行 /sktrace report。你将获得一个链接。

Server timings(服务器计时)告诉你 Skript 很昂贵,但它无法告诉你是哪个脚本、哪个触发器或哪一行代码造成的开销。skTrace 可以,因为它直接挂钩了 Skript 自身的触发器图结构,而不是从外部对 JVM 进行采样。
报告内部包含:
- 按触发器的耗时统计。 每个触发器的调用次数、总耗时、平均耗时和最差单次调用耗时,并按耗时从高到低排序,昂贵的触发器排在顶部。
- 按函数的耗时统计。 函数拥有独立的表格,因此隐藏在调用者内部的成本不再隐形。
- 行级热点分析。 可选功能,默认关闭。开启后,报告将在带有耗时列的源代码查看器中高亮显示消耗时间的确切语句。
- 与 50ms 预算对比的 Tick 图表。 拖动以选择任意范围,表格将仅针对该窗口重新构建。最差的 Tick 会有其单独的分解视图。
- 按脚本分类的时间统计。 一目了然地看出哪些文件是罪魁祸首。
- 变量变更统计。 创建、更新和删除了多少全局变量,哪些变量被写入得最多,以及每秒 Tick 的写入量迷你图。它还能检测到 Skript 定期全量重写
variables.csv 的行为,并在 Tick 图表上绘制出来,以便你查看保存操作是否与性能尖峰对齐。
- 实时循环视图。
/sktrace loops 显示当前正在运行的循环、迭代计数及其增长速率。后台看门狗会捕获真正冻结且无延迟的循环,并将确切的 script:line 记录到控制台,这是冻结期间唯一仍在工作的地方。
错过了性能尖峰?
开启滚动缓冲区,skTrace 会在后台持续进行分析。当出现尖峰时,/sktrace clip 会将过去 60 秒(可配置)的数据快照生成报告,无需预先执行 /sktrace start。开销与普通捕获相同,内存占用约为每个触发器 20KB。
专为在线服务器安全设计
按触发器、按函数和按事件的耗时统计是无害的包装器,开销可忽略不计,且在分析停止时被完全移除。变量跟踪观察 Skript 现有的保存路径,从不读取或扫描你的 variables.csv,因此即使文件巨大也不会产生额外开销。循环监控仅读取 Skript 已经维护的迭代计数器。
唯一涉及重写内容的功能 line-level-profiling(行级分析)默认处于关闭状态,并明确标记为实验性。报告中的其他所有内容均可在不启用此功能的情况下工作。
命令
|
|
/sktrace start / stop |
开始和结束捕获 |
/sktrace status |
聊天栏中的实时摘要,优先显示最热的触发器 |
/sktrace report |
生成报告并获取可分享的链接 |
/sktrace clip |
从滚动缓冲区中截取最近 N 秒的快照 |
/sktrace loops |
运行中循环的实时视图 |
/sktrace rolling on|off |
切换始终开启的缓冲区 |
/sktrace reset |
清除已收集的统计数据 |
已别名为 /skt,权限为 sktrace.use(默认为 op)。
report 和 clip 命令的标志:--no-upload 使其保持本地化,--include-files 嵌入脚本源码,--variable-values 列出每次保存压缩的内容,--show-secrets 解除选项值的掩码(选项密钥默认情况下是被掩码的)。
报告与隐私
每份报告首先写入 plugins/Sktrace/reports/ 目录。随后上传至 sktrace.kal.pe 以获取短期分享链接,分享链接在 24 小时后过期。该服务仅存储报告的 JSON 数据,从不保留原始上传的 HTML,并且每次都会使用插件自带的渲染器重新渲染每份报告。
不希望这样?将 upload-endpoint 设置为空字符串,或传递 --no-upload 参数。报告仍会本地写入,且网站可以打开你放入其中的 .json 文件。你也可以自行托管该 Worker。
除非你明确要求,否则选项值在报告中会被掩码处理,因此选项中的令牌不会出现在你在 Discord 中粘贴的链接里。
要求
Paper 或 Spigot 1.20+,Skript 2.9 或更高版本,Java 21。可与 spark 共存,后者用于分析 JVM。skTrace 用于分析 Skript。
skTrace 是一个独立项目。它与 SkriptLang 团队或 Skript 项目无关,未获其认可,也不是其一部分。

开源协议为 Apache-2.0,代码库位于 github.com/KalpeGames/skTrace。欢迎提交错误报告和拉取请求,每个版本的更新日志均存放在仓库中。
报告渲染器(report.css、report.app.js、report.shell.html)作为唯一的真实来源内置于插件中,因此本地生成的报告和共享的报告外观完全一致。分享服务是一个小型 Cloudflare Worker,保留在其自己的仓库中,你可以自由部署自己的实例并将 upload-endpoint 指向它。
匿名使用指标通过 bStats 上报:包括服务器数量、服务器软件和 Java 版本,以及是否启用了滚动缓冲区、行级分析和变量跟踪。不包含任何个人或可识别服务器的数据。设置 metrics: false 可选择退出,或在 plugins/bStats/config.yml 中一次性退出所有 bStats 插件。
更新通知程序会在启动时以及每隔几小时检查 Modrinth。当有新版本发布时,操作员在加入服务器时会收到一个可点击的通知,并且该通知会在控制台中记录一次。它永远不会下载或安装任何内容,设置 update-checker: false 可将其关闭。

Apache 许可证 2.0。使用、修改、分发,包括商业用途。保留声明并说明您的更改。
版权所有 © 2026 KALPE。
完整许可证
Find out where your server's Skript time actually goes
skTrace is a profiler built for Skript. It measures your triggers, functions, events, loops and
variable writes while the server runs, then turns that into an interactive HTML report you can open
in a browser or share with one link.
/sktrace start, let the lag happen, /sktrace report. You get a link.

Server timings tell you Skript is expensive. They do not tell you which script, which trigger,
or which line. skTrace does, because it hooks Skript's own trigger graph rather than sampling the
JVM from outside.
Inside a report:
- Per-trigger timing. Calls, total, average and worst single call for every trigger, sorted so
the expensive ones are at the top.
- Per-function timing. Functions get their own table, so cost hidden inside whatever called
them stops being invisible.
- Line-level hotspots. Optional, off by default. Turn it on and the report highlights the
exact statements eating the time, in a source viewer with a timing column.
- A tick chart against the 50ms budget. Drag to select any range and the tables rebuild for
just that window. The worst tick gets its own breakdown.
- Time by script. Which file is responsible, at a glance.
- Variable churn. How many global variables were created, updated and deleted, which ones were
written most, and a writes per tick sparkline. It also detects Skript's periodic full rewrite of
variables.csv and draws it on the tick chart, so you can see when a save lines up with a spike.
- A live loop view.
/sktrace loops shows which loops are running right now, their iteration
count and how fast it is climbing. A background watchdog catches a truly frozen no-delay loop and
logs the exact script:line to console, which is the only place still working during a freeze.
Missed the spike?
Turn on the rolling buffer and skTrace profiles continuously in the background. When something
spikes, /sktrace clip snapshots the last 60 seconds (configurable) into a report, with no
/sktrace start beforehand. Overhead is the same as a normal capture, and memory is roughly 20KB
per trigger.
Built to be safe on a live server
Per-trigger, per-function and per-event timing are passive wrappers with negligible overhead, fully
removed when profiling stops. Variable tracking observes Skript's existing save path and never
reads or scans your variables.csv, so a huge file costs nothing. Loop watching only reads the
iteration counter Skript already keeps.
The one feature that rewrites anything, line-level-profiling, is off by default and clearly
labelled experimental. Everything else in the report works without it.
Commands
|
|
/sktrace start / stop |
Begin and end a capture |
/sktrace status |
Live summary in chat, hottest triggers first |
/sktrace report |
Write the report and get a shareable link |
/sktrace clip |
Snapshot the last N seconds from the rolling buffer |
/sktrace loops |
Live view of running loops |
/sktrace rolling on|off |
Toggle the always-on buffer |
/sktrace reset |
Clear collected stats |
Aliased to /skt, permission sktrace.use (op by default).
Flags on report and clip: --no-upload keeps it local, --include-files embeds script source,
--variable-values lists what each save compacted, --show-secrets unmasks option values (option
secrets are masked by default).
Reports and privacy
Every report is written to plugins/Sktrace/reports/ first. It is then uploaded to
sktrace.kal.pe for a short share link, and shared links expire after 24
hours. The service stores only the report's JSON data, never raw uploaded HTML, and re-renders each
report from the same renderer shipped in the plugin.
Do not want that? Set upload-endpoint to an empty string, or pass --no-upload. Reports are still
written locally, and the site can open a .json file you drop into it. You can also self-host the
worker.
Option values are masked in reports unless you explicitly ask for them, so a token in an option does
not end up in a link you paste in Discord.
Requirements
Paper or Spigot 1.20+, Skript 2.9 or newer, Java 21. Works alongside
spark, which profiles the JVM. skTrace profiles Skript.
skTrace is an independent project. It is not affiliated with, endorsed by, or part of the
SkriptLang team or the Skript project.

Open source under Apache-2.0 at github.com/KalpeGames/skTrace.
Bug reports and pull requests welcome, and the changelog for every release lives in the repo.
The report renderer (report.css, report.app.js, report.shell.html) ships inside the plugin as
the single source of truth, so a locally written report and a shared one look identical. The share
service is a small Cloudflare Worker kept in its own repository, and you are free to deploy your own
and point upload-endpoint at it.
Anonymous usage metrics go through bStats: server
count, server software and Java version, plus whether the rolling buffer, line-level profiling and
variable tracking are enabled. No personal or server-identifying data. Set metrics: false to opt
out, or opt every bStats plugin out at once in plugins/bStats/config.yml.
An update notifier checks Modrinth on startup and every few hours after. When a newer release is
out, operators get a clickable notice on join and it is logged once to console. It never downloads
or installs anything, and update-checker: false turns it off.

Apache License 2.0. Use it, modify it, ship it, including commercially. Keep the notice and state
your changes.
Copyright © 2026 KALPE.
Full licence
评论 0
登录后参与评分
还没有评论,来抢沙发吧