Skip to content

fix: create base results directory #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/lib/write-results.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MultipleBenchmarkRunResults, ORM, Database, BenchmarkOptions } from "./types";
import type { MultipleBenchmarkRunResults, ORM, Database, BenchmarkOptions } from "./types";
import * as fs from "fs";
import * as path from 'path';
import * as path from "path";

export default function writeResults(
orm: ORM,
Expand All @@ -9,9 +9,18 @@ export default function writeResults(
benchmarkOptions: BenchmarkOptions,
resultsDirectoryTimestamp: string
) {
// Create base results directory if it doesn't exist
const baseResultsDir = path.join(".", "results");
if (!fs.existsSync(baseResultsDir)) {
fs.mkdirSync(baseResultsDir);
console.log(`Created base results directory: ${baseResultsDir}`);
}

// Create dedicated results directory for this benchmark run
const resultsDir = path.join('.', `results/${db}-${benchmarkOptions.size}-${benchmarkOptions.iterations}-${resultsDirectoryTimestamp}`);
const resultsDir = path.join(
".",
`results/${db}-${benchmarkOptions.size}-${benchmarkOptions.iterations}-${resultsDirectoryTimestamp}`
);

if (!fs.existsSync(resultsDir)) {
fs.mkdirSync(resultsDir);
Expand All @@ -26,7 +35,7 @@ export default function writeResults(

// Extract rows
const rows = results.map((batch) => {
const row: { [key: string]: number | string; } = {};
const row: { [key: string]: number | string } = {};
batch.forEach((item) => {
row[item.query] = item.time;
});
Expand Down