mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 18:09:29 +08:00
13 lines
488 B
JavaScript
13 lines
488 B
JavaScript
// Bench-side lines for the write trace (HF_WRITE_TRACE), in the same file as the server's.
|
|
import { appendFileSync } from "node:fs";
|
|
import { createHash } from "node:crypto";
|
|
|
|
export const traceBench = (kind, data = {}) => {
|
|
if (process.env.HF_WRITE_TRACE)
|
|
appendFileSync(
|
|
process.env.HF_WRITE_TRACE,
|
|
JSON.stringify({ t: Date.now(), kind, ...data }) + "\n",
|
|
);
|
|
};
|
|
export const hashOf = (text) => createHash("sha256").update(String(text)).digest("hex").slice(0, 8);
|