-
-
Notifications
You must be signed in to change notification settings - Fork 197
Kddimitrov/track perf decorator #4242
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
Conversation
lib/services/performance-service.ts
Outdated
let methodArgs; | ||
|
||
try { | ||
methodArgs = JSON.stringify(args, this.getCircularReplacer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just use something like circular-json
(we already have it in our dependencies tree)
lib/common/decorators.ts
Outdated
const performanceService: IPerformanceService = injector.resolve("performanceService"); | ||
|
||
//needed for the returned function to have the same name as the original - used in hooks decorator | ||
const tempObject = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempObject -> functionWrapper
lib/common/decorators.ts
Outdated
return result; | ||
} | ||
}; | ||
descriptor.value = tempObject[originalMethod.name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a little bit risky, we need to cover it with unit tests for not hiding exceptions, results, not affecting the call stack and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add tests for the decorator once the implementation is final.
lib/common/helpers.ts
Outdated
@@ -567,6 +567,33 @@ export function stringify(value: any, replacer?: (key: string, value: any) => an | |||
return JSON.stringify(value, replacer, space || 2); | |||
} | |||
|
|||
export function getFormattedDate(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFormattedDate
in which format? As far as I see it makes the date strings orderable and it could be something like getOrderableDateString. Also, we could make it accept the Date as an argument in order to make it unit testable.
|
||
export function performanceLog(injector?: IInjector): any { | ||
injector = injector || $injector; | ||
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we skip this logic based on $options.performance
?
f22993f
to
7d636c0
Compare
7358b16
to
5265bba
Compare
5265bba
to
e97247e
Compare
run ci |
Logs from hooks not longer displayed in output after NativeScript/nativescript-cli#4242 This is expected.
PR Checklist
What is the current behavior?
We have no means of consistent profiling and tracking performance of our methods, while executing commands.
What is the new behavior?
We will send performance analytics if usage-reporting is enabled. If
--performance
flag is added to the command all profiling information will be included in the command output. If--performance
options is set to a file path, the profiling information will be saved inside the file.Fixes/Implements/Closes #4243