Skip to content

log: Add support for slf4j-style parameterised logging #51

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

Merged
merged 1 commit into from
Jan 30, 2021

Conversation

jasraj
Copy link
Member

@jasraj jasraj commented Jan 29, 2021

Testing:

/ model name      : Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz

/ Setup
q) .require.lib`log; .log.setLevel`DEBUG;
q) sym:`a;
q) dict:`a`b`c!1 2 3;
q) table:flip `a`b`c!2?/:(`3; 1f; 100j);

// Logging enabled
q) .log.info "A symbol: ",string sym;                                   / Old format
q) if[.log.isLoggingAt `DEBUG; .log.debug "A symbol: ",string sym ];    / Old with log level check
q) .log.info ("A symbol: {}"; sym);                                     / New (slf4j-style) format

// Logging disabled
q) .log.trace "A symbol: ",string sym;                                  / Old format
q) if[.log.isLoggingAt `TRACE; .log.trace "A symbol: ",string sym ];    / Old with log level check
q) .log.trace ("A symbol: {}"; sym);                                    / New (slf4j-style) format

Results:

Outputs Format Iterations ts
YES Old 1000 * Atom: 32 4196240
* Dict: 18 4195840
* Table: 118 4195904
YES Old with check 1000 * Atom: 36 4196496
* Dict: 18 4196096
* Table: 115 4196160
YES New 1000 * Atom: 33 4195456
* Dict: 21 4195344
* Table: 118 4195344
NO Old 10000 * Atom: 5 2336
* Dict: 94 1808
* Table: 196 2464
NO Old with check 10000 * Atom: 12 3120
* Dict: 11 2208
* Table: 12 2208
NO New 10000 * Atom: 2 1984
* Dict: 2 1680
* Table: 2 1712

When the log level is output to standard out / standard error the performance of all 3 mechanism is more-or-less the same.

However, when the log level is disabled, there is a significant increase in performance with the new logging format, particularly if the object to be printed is a complex object (generally deferring to .Q.s1).

@jasraj jasraj marked this pull request as ready for review January 30, 2021 14:45
@jasraj jasraj force-pushed the slf4j-parameterised-logging branch from 61201b0 to fe9d8e0 Compare January 30, 2021 14:59
@jasraj jasraj merged commit 29cd6aa into master Jan 30, 2021
@jasraj jasraj deleted the slf4j-parameterised-logging branch January 30, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant