Skip to content

Instantly share code, notes, and snippets.

@paulfryzel
Created December 5, 2013 01:23
Show Gist options
  • Save paulfryzel/7798674 to your computer and use it in GitHub Desktop.
Save paulfryzel/7798674 to your computer and use it in GitHub Desktop.
function Foo(obj) {
this.obj = obj;
this.time = Date.now();
}
function create() {
for (var i = 0; i < 1e6; i++) {
var f = new Foo({ foo: 42 });
}
}
create();
@paulfryzel
Copy link
Author

Statistical profiling result from v8.log, (117 ticks, 2 unaccounted, 0 excluded).

 [Unknown]:
   ticks  total  nonlib   name
      2    1.7%

 [Shared libraries]:
   ticks  total  nonlib   name

 [JavaScript]:
   ticks  total  nonlib   name
     15   12.8%   12.8%  LazyCompile: *create ctor.js:6:16
      4    3.4%    3.4%  LazyCompile: *now native date.js:179:17
      3    2.6%    2.6%  Stub: CEntryStub
      1    0.9%    0.9%  Stub: ToBooleanStub(Undefined,SpecObject)
      1    0.9%    0.9%  Builtin: A builtin from the snapshot

 [C++]:
   ticks  total  nonlib   name
     56   47.9%   47.9%  start
     23   19.7%   19.7%  _vm_read_list
      9    7.7%    7.7%  _clock_sleep
      2    1.7%    1.7%  _openpty
      1    0.9%    0.9%  _vm_purgable_control
      1    0.9%    0.9%  _mach_vm_map
      1    0.9%    0.9%  __simple_sfree

 [GC]:
   ticks  total  nonlib   name
      4    3.4%

 [Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 2.0% are not shown.

  1 function Foo(obj) {
   ticks parent  name
     56   47.9%  start
     25   44.6%    LazyCompile: *now native date.js:179:17
     25  100.0%      LazyCompile: *create ctor.js:6:16
     25  100.0%        Script: ~ctor.js
      2    3.6%    LazyCompile: ~create ctor.js:6:16
      2  100.0%      Script: ~ctor.js
      2    3.6%    LazyCompile: InstantiateFunction native apinatives.js:26:29
      2  100.0%      LazyCompile: ~Instantiate native apinatives.js:9:21

     23   19.7%  _vm_read_list
     23  100.0%    LazyCompile: *now native date.js:179:17
     22   95.7%      LazyCompile: *create ctor.js:6:16
     22  100.0%        Script: ~ctor.js
      1    4.3%      LazyCompile: *Foo ctor.js:1:13
      1  100.0%        LazyCompile: ~create ctor.js:6:16
      1  100.0%          Script: ~ctor.js

     15   12.8%  LazyCompile: *create ctor.js:6:16
     15  100.0%    Script: ~ctor.js

      9    7.7%  _clock_sleep
      9  100.0%    LazyCompile: *now native date.js:179:17
      9  100.0%      LazyCompile: *create ctor.js:6:16
      9  100.0%        Script: ~ctor.js

      4    3.4%  LazyCompile: *now native date.js:179:17
      4  100.0%    LazyCompile: *create ctor.js:6:16
      4  100.0%      Script: ~ctor.js

      3    2.6%  Stub: CEntryStub
      2   66.7%    LazyCompile: *now native date.js:179:17
      2  100.0%      LazyCompile: *create ctor.js:6:16
      2  100.0%        Script: ~ctor.js
      1   33.3%    LazyCompile: *create ctor.js:6:16
      1  100.0%      Script: ~ctor.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment