screeps-typescript-profiler
screeps-typescript-profiler copied to clipboard
Static functions not displaied
Hello, First of all, thank you for this profiler. It all works fine with the exception of static functions. I had a class with static functions but only after I converted them to non-static functions, they started to appear in the log.
That is how the profiler operates, even in vanilla JS. it only loops through the prototype. any static functions need to be registered individually: SomeClass.someFunc = profiler.registerFN(SomeClass.someFunc, 'SomeClass.someFunc');
Thank for clarification. Where would I put that line, I believe in the init function of the Profiler? And registerFn does not exists in this context, did you meant something else by any chance?
I meant this... https://github.com/screepers/screeps-profiler/blob/master/screeps-profiler.js#L171-L180. if that is unavailable, then i suppose yall are using a different version. I would recommend including the original if youre having trouble with it. the readme's examples section has an example of it in the very bottom. and you would call it before you profiler.enable();
I did not install the screeps-profiler module. I only installed and followed the instructions from screeps-typescript-profiler, didn't expect would need the js variant as well. I thought this would be an alternative to the js variant.
It seems like it's possible to get the static members from a class, so it seems they could also be picked up dynamically if the decorator is used on the class. https://stackoverflow.com/questions/33069692/getting-a-list-of-statics-on-an-es6-class
Is it intentional to exclude them? If there isn't a desire not include them by default, it could be made conditional.
@profile({includeStatic:true})
class MyClass {
public static doStuff: void {
// this would be profiled
}
}
@profile
class MyClass {
public static doStuff: void {
// current behavior, not profiled
}
}
@pyrodogg How hard would that be to add? Pretty much all of my code is static methods which makes this not so useful and I'd really love to be able to use it.
I'll look at a PR early this week so it can be tested.
See the PR #10 You can of course just clone my repo until this PR is approved