mirror of
https://github.com/silvanocerza/github-gitless-sync.git
synced 2026-07-22 05:41:36 +00:00
Adjust benchmark script with new imports and add some more progress logs
This commit is contained in:
parent
263623dad7
commit
53651f5b88
1 changed files with 12 additions and 5 deletions
17
benchmark.ts
17
benchmark.ts
|
|
@ -12,10 +12,6 @@ const LoggerModule = proxyquireNonStrict("./src/logger", {
|
||||||
obsidian: obsidianMocks,
|
obsidian: obsidianMocks,
|
||||||
});
|
});
|
||||||
|
|
||||||
const GithubClientModule = proxyquireNonStrict("./src/github/client", {
|
|
||||||
obsidian: obsidianMocks,
|
|
||||||
});
|
|
||||||
|
|
||||||
const MetadataStoreModule = proxyquireNonStrict("./src/metadata-store", {
|
const MetadataStoreModule = proxyquireNonStrict("./src/metadata-store", {
|
||||||
obsidian: obsidianMocks,
|
obsidian: obsidianMocks,
|
||||||
});
|
});
|
||||||
|
|
@ -29,6 +25,11 @@ const UtilsModule = proxyquireNonStrict("./src/utils", {
|
||||||
obsidian: obsidianMocks,
|
obsidian: obsidianMocks,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const GithubClientModule = proxyquireNonStrict("./src/github/client", {
|
||||||
|
obsidian: obsidianMocks,
|
||||||
|
"src/utils": UtilsModule,
|
||||||
|
});
|
||||||
|
|
||||||
const SyncManagerModule = proxyquireNonStrict("./src/sync-manager", {
|
const SyncManagerModule = proxyquireNonStrict("./src/sync-manager", {
|
||||||
obsidian: obsidianMocks,
|
obsidian: obsidianMocks,
|
||||||
"./metadata-store": MetadataStoreModule,
|
"./metadata-store": MetadataStoreModule,
|
||||||
|
|
@ -228,7 +229,7 @@ const BENCHMARK_DATA = [
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const data of BENCHMARK_DATA) {
|
for (const data of BENCHMARK_DATA) {
|
||||||
console.log(
|
console.log(
|
||||||
`Running benchmark for ${data.files} files of ${data.fileSize} bytes`,
|
`Running benchmark with ${data.files} files totaling ${data.fileSize} bytes`,
|
||||||
);
|
);
|
||||||
const vaultRootDir = path.join(
|
const vaultRootDir = path.join(
|
||||||
benchmarkRootDir,
|
benchmarkRootDir,
|
||||||
|
|
@ -243,12 +244,14 @@ const BENCHMARK_DATA = [
|
||||||
);
|
);
|
||||||
|
|
||||||
// Run first sync by uploading all local files
|
// Run first sync by uploading all local files
|
||||||
|
console.log("First sync from local");
|
||||||
const uploadTime = await runBenchmark(vaultRootDir);
|
const uploadTime = await runBenchmark(vaultRootDir);
|
||||||
|
|
||||||
// Cleanup vault dir completely
|
// Cleanup vault dir completely
|
||||||
fs.rmSync(vaultRootDir, { recursive: true, force: true });
|
fs.rmSync(vaultRootDir, { recursive: true, force: true });
|
||||||
|
|
||||||
// Run first sync again, this time we download the files we just uploaded
|
// Run first sync again, this time we download the files we just uploaded
|
||||||
|
console.log("Second sync from remote");
|
||||||
const downloadTime = await runBenchmark(vaultRootDir);
|
const downloadTime = await runBenchmark(vaultRootDir);
|
||||||
|
|
||||||
// Cleanup the remote repo so it's ready for another benchmark
|
// Cleanup the remote repo so it's ready for another benchmark
|
||||||
|
|
@ -262,6 +265,10 @@ const BENCHMARK_DATA = [
|
||||||
|
|
||||||
// Cleanup vault dir again, it's not necessary to keep it around
|
// Cleanup vault dir again, it's not necessary to keep it around
|
||||||
fs.rmSync(vaultRootDir, { recursive: true, force: true });
|
fs.rmSync(vaultRootDir, { recursive: true, force: true });
|
||||||
|
|
||||||
|
// Wait 2 seconds between each run just to avoid annoying Github
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||||
|
console.log("");
|
||||||
}
|
}
|
||||||
fs.writeFileSync("benchmark_result.json", JSON.stringify(results), {
|
fs.writeFileSync("benchmark_result.json", JSON.stringify(results), {
|
||||||
flag: "w",
|
flag: "w",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue