Skip to content

Commit

Permalink
test: logger specific tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 27, 2023
1 parent b04ec41 commit d3a051a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/perf/logger/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,32 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Suite } from 'benchmark';
import { Logger } from '../../../src/exported';

const suite = new Suite();

const logger = new Logger('Benchmarks');

// add tests
suite
.add('RegExp#test', () => {
.add('Child logger creation', () => {
// eslint-disable-next-line @typescript-eslint/prefer-includes
/o/.test('Hello World!');
Logger.childFromRoot('benchmarkChild');
})
.add('Logging a string on root logger', () => {
logger.debug('this is a string');
})
.add('Logging an object on root logger', () => {
logger.debug({ foo: 1, bar: 2, baz: 3 });
})
.add('Logging an object with a message on root logger', () => {
logger.debug({ foo: 1, bar: 2, baz: 3 }, 'this is a message');
})
.add('Logging an object with a redacted prop on root logger', () => {
logger.debug({ foo: 1, bar: 2, accessToken: '00D' });
})
.add('String#indexOf', () => {
'Hello World!'.includes('o');
.add('Logging a nested 3-level object on root logger', () => {
logger.debug({ foo: 1, bar: 2, baz: { foo: 1, bar: 2, baz: { foo: 1, bar: 2, baz: 3 } } });
})
// add listeners
.on('cycle', (event: any) => {
Expand Down

1 comment on commit d3a051a

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: d3a051a Previous: b04ec41 Ratio
Child logger creation 9475 ops/sec (±1.75%)
Logging a string on root logger 73197496 ops/sec (±2.38%)
Logging an object on root logger 40450300 ops/sec (±1.75%)
Logging an object with a message on root logger 27395750 ops/sec (±1.34%)
Logging an object with a redacted prop on root logger 41176783 ops/sec (±0.99%)
Logging a nested 3-level object on root logger 18689169 ops/sec (±1.11%)

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.