-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce client logger overhead (#960)
* Add a benchmark suite for the client logger We do a lot of logging in the browser, so it's worth measuring overhead. * Lower client logger overhead * Lower classification overhead * Tuple batching * No transport short circuit * Lazy args init
- Loading branch information
Showing
3 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {Suite} from "benchmark"; | ||
import logging from "../logging/client"; | ||
|
||
const n = 1000; | ||
|
||
let enclosedDeferred; | ||
|
||
class NoopTransport { | ||
constructor() { | ||
this.name = 'noop'; | ||
this.level = 'info'; | ||
} | ||
|
||
log(level, msg, meta, callback) { | ||
if (meta === n || meta.ms === n) { | ||
enclosedDeferred.resolve(); | ||
} | ||
callback(null, true); | ||
} | ||
} | ||
|
||
class NoopTimeTransport extends NoopTransport { | ||
constructor() { | ||
super(); | ||
this.level = 'fast'; | ||
} | ||
} | ||
|
||
const noTransportLogger = logging.getLogger({name: "noTransports"}); | ||
const noopTransportLogger = logging.getLogger({name: "noopTransport"}); | ||
|
||
noopTransportLogger.add(NoopTransport) | ||
noopTransportLogger.timeLogger.add(NoopTimeTransport) | ||
|
||
function run(logger, method) { | ||
return function(deferred) { | ||
enclosedDeferred = deferred; | ||
for (var i = 1; i <= n; i++) { | ||
logger[method]("test", i); | ||
} | ||
} | ||
} | ||
|
||
new Suite() | ||
.add("info no transports", run(noTransportLogger, 'info')) | ||
.add("info noop transport", run(noopTransportLogger, 'info'), { defer: true }) | ||
.add("time no transports", run(noTransportLogger, 'time')) | ||
.add("time noop transport", run(noopTransportLogger, 'time'), { defer: true }) | ||
.on('cycle', (v) => console.log(v.target.name + "\t" + v.target.stats.mean)) | ||
.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters