-
Notifications
You must be signed in to change notification settings - Fork 927
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
Profiling Javascript with quickjs ? #183
Comments
I've got an initial implementation of it that outputs something like:
That after processing can output this:
|
Just did this pull request #184 with my initial working implementation. |
Here is a sample script to format the output :
|
Definitely interesting! Will look into merging your pull request. |
I tried to use the PR linked above, but I always get Anyway, adding an |
Hello @rubenlg thanks for reply ! |
Thanks @mingodad ! Of course, I don't want to include this in release mode. I was just worried that the overhead will skew the results of the performance measurements. By the way, I just noticed that it only works for free functions. Class methods and functions declared inside objects have a null atom in the |
@rubenlg can you give a minimal example with the actual output ? |
Sure. Here is a minimal example exercising the three cases (toplevel function, function inside object, and class): function test1() {}
const obj = {
test2() {}
};
class K {
test3() {}
}
test1();
obj.test2();
new K().test3(); Here is the output of your original patch applied to the latest version of quickjs:
Already there only the toplevel function has a non-null atom, even if it's gone by the time the code dumps these stats. Here is the output with the changes I mentioned (saving the function name inside
At least the toplevel function works now, but the others are still showing a null atom in the function name. I've been trying to hack something using the stack frames but not understanding the code well enough it's like shooting in the dark. |
By looking at how stack frames are computed in
|
@rubenlg thank you ! |
I need to clean it up a bit, it's leaking memory. And I want to show the context for functions that are not toplevel (e.g. show |
Ok ! @rubenlg thank you again ! |
I just sent #371 with the fixes mentioned above and a slightly different implementation that produces traces that can be open in the chrome devtools and a bunch of other external tools, where you can still get aggregated results, but also see the reconstructed call stacks, etc. |
Hello @rubenlg thank you again I just closed my pull request pointing out that your is a improved one. |
Does someone managed to profile Javascript code with quikjs ?
Ideally
qjs
would have an option to save/output a profile report of the running script, something like:I'm looking at the source code to try find the ideal point to install hooks that allow such functionality, any help is welcome !
Cheers !
The text was updated successfully, but these errors were encountered: