Kddimitrov/track perf decorator#4242
Conversation
| let methodArgs; | ||
|
|
||
| try { | ||
| methodArgs = JSON.stringify(args, this.getCircularReplacer()); |
There was a problem hiding this comment.
Can't we just use something like circular-json (we already have it in our dependencies tree)
| 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.
tempObject -> functionWrapper
| return result; | ||
| } | ||
| }; | ||
| descriptor.value = tempObject[originalMethod.name]; |
There was a problem hiding this comment.
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.
Will add tests for the decorator once the implementation is final.
| return JSON.stringify(value, replacer, space || 2); | ||
| } | ||
|
|
||
| export function getFormattedDate(): string { |
There was a problem hiding this comment.
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.
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
--performanceflag is added to the command all profiling information will be included in the command output. If--performanceoptions is set to a file path, the profiling information will be saved inside the file.Fixes/Implements/Closes #4243