Closed ALEXKIRNAS closed 7 years ago
@ALEXKIRNAS thanks for your contribution! Feel free to ping me if you have any questions or you'll need help with fixing any of the issues and nits mentioned above or the ones that may be found during the further review.
@aqrln I already fixed problems, that you described. And I have a question. I want to test a speed of creating object in file "c-obj-create.js" when I run it like "node c-obj-create.js". But I wan`t to see this test when I use this file as module in other programs. Have can I do this?
@ALEXKIRNAS probably the easiest way to do it is
if (module.parent === null) {
// this code will only be executed when the file is run as a script,
// not when it is required by other modules
}
I already fixed problems, that you described.
Not all of them. The .eslintrc.yml
file is still present in the PR and I still ask you to rebase your branch on top of master
:)
@aqrln Fixed. And another question. How I can add name to functions? Now my version looks like this:
creaters.mixinCreate = function mixinCreate() { // Here my code };
@ALEXKIRNAS well, that's the only way. V8 is pretty good at constructing function names itself for stacktraces, but fn.name
works with named functions only.
I'd prefer the benchmarking framework to not rely upon fn.name
though.
@aqrln It's easy to fix up. We can add new argument (array of function`s names) when we call function. Then inside benchmark.do function we choose name for displaying in next order:
@ALEXKIRNAS PRs are welcome, go for it :)
@aqrln Done.
@ALEXKIRNAS it must be a different PR.
@aqrln You mean create new branch and make new PR?
Yep. This PR is about object creation benchmarking, not about the benchmarking tools.
@aqrln Okay. I delete it from this PR and add new PR.
@aqrln Fixed.
Adding test of different methods of creating objects in JS. Compare speed of creating + using objects. Creating objects using:
In my realization time of runs: prototypes <= classes < closures <= mixing