@lbu/insight
Advanced tools
Comparing version 0.0.67 to 0.0.68
{ | ||
"name": "@lbu/insight", | ||
"version": "0.0.67", | ||
"version": "0.0.68", | ||
"description": "Simple logger in NDJSON format", | ||
@@ -36,3 +36,3 @@ "main": "./index.js", | ||
}, | ||
"gitHead": "d42fb37f605b5130899ae4c936f824854927ecf9" | ||
"gitHead": "492675053e2de2236eefb2fd467a66f3862b0b6b" | ||
} |
import { createWriteStream } from "fs"; | ||
import { bench, logBenchResults, mainFn } from "@lbu/stdlib"; | ||
import { bench, mainBenchFn } from "@lbu/cli"; | ||
import { newLogger } from "./logger.js"; | ||
mainFn(import.meta, async (logger) => { | ||
await runBench(); | ||
logBenchResults(logger); | ||
}); | ||
mainBenchFn(import.meta); | ||
export async function runBench() { | ||
await bench("logger - strings", (N) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
}); | ||
bench("logger - strings", (b) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
}); | ||
for (let i = 0; i < N; ++i) { | ||
logger.info("My simple string"); | ||
} | ||
for (let i = 0; i < b.N; ++i) { | ||
logger.info("My simple string"); | ||
} | ||
stream.end(); | ||
stream.end(); | ||
}); | ||
bench("logger - objects", (b) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
}); | ||
await bench("logger - objects", (N) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
for (let i = 0; i < b.N; ++i) { | ||
logger.info({ | ||
my: { | ||
simple: "object", | ||
}, | ||
}); | ||
} | ||
for (let i = 0; i < N; ++i) { | ||
logger.info({ | ||
my: { | ||
simple: "object", | ||
}, | ||
}); | ||
} | ||
stream.end(); | ||
}); | ||
stream.end(); | ||
bench("logger - deep objects", (b) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
}); | ||
await bench("logger - deep objects", (N) => { | ||
const stream = createWriteStream("/tmp/logger_bench_lbu.txt", "utf-8"); | ||
const logger = newLogger({ | ||
pretty: false, | ||
stream, | ||
for (let i = 0; i < b.N; ++i) { | ||
logger.info({ | ||
my: { | ||
more: [ | ||
{ | ||
advanced: { | ||
object: "with", | ||
multiple: "keys", | ||
foo: 5, | ||
}, | ||
}, | ||
], | ||
}, | ||
bar: true, | ||
}); | ||
} | ||
for (let i = 0; i < N; ++i) { | ||
logger.info({ | ||
my: { | ||
more: [ | ||
{ | ||
advanced: { | ||
object: "with", | ||
multiple: "keys", | ||
foo: 5, | ||
}, | ||
}, | ||
], | ||
}, | ||
bar: true, | ||
}); | ||
} | ||
stream.end(); | ||
}); | ||
} | ||
stream.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13981
327