* i wanted to make sure `undefined` was handled properly. seems like it is. * tested with Bun, works. Deno runs faster though, by about 1.8µs/message construction! * Removed skeletons from closet (bug fixes) * Sources can now optionally specify their own time format and/or log timing * Requests and Responses now can be converted and displayed (no bodies)
109 lines
2.5 KiB
TypeScript
109 lines
2.5 KiB
TypeScript
import Logging, { LogTiming, MessageType } from "@proxnet/undead-logging";
|
|
import chalk from "chalk";
|
|
|
|
// SYNC
|
|
|
|
Deno.bench({
|
|
name: "1 Log",
|
|
group: "timing-sync",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "100 Logs",
|
|
group: "timing-sync",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
for (let i = 0; i < 100; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "1k Logs",
|
|
group: "timing-sync",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
for (let i = 0; i < 1_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "10k Logs",
|
|
group: "timing-sync",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
for (let i = 0; i < 10_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "100k Logs",
|
|
group: "timing-sync",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.logTiming = LogTiming.Deferred;
|
|
for (let i = 0; i < 100_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
// DEFERRED
|
|
|
|
Deno.bench({
|
|
name: "1 Log",
|
|
group: "timing-deferred",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.logTiming = LogTiming.Deferred;
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "100 Logs",
|
|
group: "timing-deferred",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.logTiming = LogTiming.Deferred;
|
|
for (let i = 0; i < 100; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "1k Logs",
|
|
group: "timing-deferred",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.logTiming = LogTiming.Deferred;
|
|
for (let i = 0; i < 1_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "10k Logs",
|
|
group: "timing-deferred",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
log.logTiming = LogTiming.Deferred;
|
|
for (let i = 0; i < 10_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
});
|
|
|
|
Deno.bench({
|
|
name: "100k Logs",
|
|
group: "timing-deferred",
|
|
fn: () => {
|
|
const log = new Logging("Bench");
|
|
for (let i = 0; i < 100_000; i++)
|
|
log.bench(MessageType.Info, chalk.black, 'a');
|
|
}
|
|
}); |