mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-23 09:33:20 +00:00
21 lines
839 B
TypeScript
21 lines
839 B
TypeScript
import { computeFileContentHash } from "@vrtmrz/livesync-commonlib/hashing";
|
|
import { xxhashNew } from "octagonal-wheels/hash/xxhash.js";
|
|
import {
|
|
createFixedFileContentHashInput,
|
|
type FileContentHashBenchmarkOperations,
|
|
} from "./reviewHarnessFileContentHashBenchmark";
|
|
|
|
export async function createFileContentHashBenchmarkOperations(
|
|
clock: Pick<Performance, "now"> = performance
|
|
): Promise<FileContentHashBenchmarkOperations> {
|
|
const started = clock.now();
|
|
const xxHash = await xxhashNew();
|
|
const xxHashInitialisationMs = clock.now() - started;
|
|
return {
|
|
xxHashInitialisationMs,
|
|
createInput: createFixedFileContentHashInput,
|
|
sha256: (content) => computeFileContentHash(content),
|
|
xxHash64: async (content) => xxHash.h64Raw(new Uint8Array(await content.arrayBuffer())),
|
|
};
|
|
}
|