Skip to content

Instantly share code, notes, and snippets.

@fredrick
Created January 12, 2012 21:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrick/1603404 to your computer and use it in GitHub Desktop.
Save fredrick/1603404 to your computer and use it in GitHub Desktop.
Node.JS + v8 profiling
Array = require('gauss').Vector;
var prices = [22.2734, 22.194, 22.0847, 22.1741, 22.184, 22.1344,
22.2337, 22.4323, 22.2436, 22.2933, 22.1542, 22.3926,
22.3816, 22.6109, 23.3558, 24.0519, 23.753, 23.8324,
23.9516, 23.6338, 23.8225, 23.8722, 23.6537, 23.187,
23.0976, 23.326, 22.6805, 23.0976, 22.4025, 22.1725];
/* Use Wilder ratio on an exponential moving average period of 10,
1 million iterations
*/
for (var i = 0; i < 1000000; i++) {
prices.ema({
period: 10,
ratio: function(n) {
return (1 / n);
}
});
}
Running: node --prof --log-snapshot-positions --logfile=profile-13264057338989582.log ema.wilder.js
Statistical profiling result from profile-13264057338989582.log, (5343 ticks, 38 unaccounted, 0 excluded).
[Unknown]:
ticks total nonlib name
38 0.7%
[Shared libraries]:
ticks total nonlib name
2525 47.3% 0.0% /usr/local/bin/node
[JavaScript]:
ticks total nonlib name
709 13.3% 25.2% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
354 6.6% 12.6% LazyCompile: Join native array.js:100
257 4.8% 9.1% KeyedLoadIC: {80}
167 3.1% 5.9% Stub: NumberToString
104 1.9% 3.7% Stub: TypeRecordingBinaryOpStub_SUB_Alloc_HeapNumbers
89 1.7% 3.2% LazyCompile: DefaultNumber native runtime.js:603
86 1.6% 3.1% LazyCompile: Array.sum /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:39
79 1.5% 2.8% Stub: TypeRecordingBinaryOpStub_MUL_OverwriteRight_HeapNumbers
71 1.3% 2.5% KeyedStoreIC: {81}
64 1.2% 2.3% Stub: CEntry
63 1.2% 2.2% LazyCompile: NonNumberToNumber native runtime.js:514
63 1.2% 2.2% Builtin: A builtin from the snapshot
50 0.9% 1.8% Stub: TypeRecordingBinaryOpStub_ADD_Alloc_HeapNumbers
47 0.9% 1.7% LazyCompile: options.ratio /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:308
46 0.9% 1.6% LazyCompile: DIV native runtime.js:223
44 0.8% 1.6% Stub: TypeRecordingBinaryOpStub_ADD_OverwriteLeft_HeapNumbers
34 0.6% 1.2% LazyCompile: toString native array.js:361
30 0.6% 1.1% Stub: TypeRecordingBinaryOpStub_DIV_Alloc_Generic
26 0.5% 0.9% Stub: FastNewClosure
21 0.4% 0.7% Stub: TypeRecordingBinaryOpStub_DIV_OverwriteRight_SMI
21 0.4% 0.7% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
20 0.4% 0.7% Stub: CallFunction
18 0.3% 0.6% LazyCompile: ToNumber native runtime.js:503
16 0.3% 0.6% LazyCompile: UseSparseVariant native array.js:92
15 0.3% 0.5% Stub: TypeRecordingBinaryOpStub_DIV_Alloc_HeapNumbers
14 0.3% 0.5% Builtin: A builtin from the snapshot {1}
10 0.2% 0.4% LazyCompile: ToObject native runtime.js:543
8 0.1% 0.3% LazyCompile: IsPrimitive native runtime.js:594
8 0.1% 0.3% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:17
7 0.1% 0.2% Stub: FastCloneShallowArray
6 0.1% 0.2% Stub: TypeRecordingBinaryOpStub_SUB_Alloc_SMI
6 0.1% 0.2% Stub: CompareIC {1}
6 0.1% 0.2% Builtin: A builtin from the snapshot {2}
5 0.1% 0.2% Stub: JSEntry
4 0.1% 0.1% Stub: CompareIC
4 0.1% 0.1% Builtin: A builtin from the snapshot {3}
3 0.1% 0.1% Stub: ToBoolean
2 0.0% 0.1% Stub: TypeRecordingBinaryOpStub_ADD_Alloc_SMI
2 0.0% 0.1% LazyCompile: valueOf native v8natives.js:222
1 0.0% 0.0% Stub: TypeRecordingBinaryOpStub_BIT_OR_Alloc_Uninitialized
1 0.0% 0.0% Stub: SubString
1 0.0% 0.0% Builtin: A builtin from the snapshot {4}
[C++]:
ticks total nonlib name
100 1.9% 3.5% _chmod
53 1.0% 1.9% _dbm_open
52 1.0% 1.8% ___gettimeofday
5 0.1% 0.2% _proc_listpidspath
5 0.1% 0.2% _mig_dealloc_reply_port
2 0.0% 0.1% _semaphore_wait_signal_trap
2 0.0% 0.1% _mergesort
2 0.0% 0.1% ___Balloc_D2A
1 0.0% 0.0% _vm_region_64
1 0.0% 0.0% _tiny_free_try_depot_unmap_no_lock
1 0.0% 0.0% _szone_realloc
1 0.0% 0.0% _small_malloc_from_free_list
1 0.0% 0.0% _pthread_workqueue_create_np
1 0.0% 0.0% _fgets
1 0.0% 0.0% _fclose
1 0.0% 0.0% _dbm_fetch
1 0.0% 0.0% _abort
1 0.0% 0.0% __pthread_start
1 0.0% 0.0% __pthread_mutex_init
1 0.0% 0.0% __asl_server_prune
1 0.0% 0.0% ___vfprintf
[GC]:
ticks total nonlib name
72 1.3%
[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.
ticks parent name
2525 47.3% /usr/local/bin/node
1640 65.0% LazyCompile: Join native array.js:100
1640 100.0% LazyCompile: toString native array.js:361
1640 100.0% LazyCompile: DefaultNumber native runtime.js:603
1640 100.0% LazyCompile: NonNumberToNumber native runtime.js:514
1640 100.0% LazyCompile: DIV native runtime.js:223
314 12.4% LazyCompile: options.ratio /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:308
314 100.0% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
314 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
314 100.0% Function: Module._compile module.js:349
314 100.0% Function: Module._extensions module.js:415
290 11.5% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
290 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
290 100.0% Function: Module._compile module.js:349
290 100.0% Function: Module._extensions module.js:415
290 100.0% Function: Module.load module.js:333
102 4.0% LazyCompile: ToNumber native runtime.js:503
102 100.0% LazyCompile: NonNumberToNumber native runtime.js:514
102 100.0% LazyCompile: DIV native runtime.js:223
102 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:17
102 100.0% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
709 13.3% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
708 99.9% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
708 100.0% Function: Module._compile module.js:349
708 100.0% Function: Module._extensions module.js:415
708 100.0% Function: Module.load module.js:333
708 100.0% Function: Module._load module.js:266
354 6.6% LazyCompile: Join native array.js:100
352 99.4% LazyCompile: toString native array.js:361
352 100.0% LazyCompile: DefaultNumber native runtime.js:603
352 100.0% LazyCompile: NonNumberToNumber native runtime.js:514
352 100.0% LazyCompile: DIV native runtime.js:223
352 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:17
257 4.8% KeyedLoadIC: {80}
154 59.9% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
154 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
154 100.0% Function: Module._compile module.js:349
154 100.0% Function: Module._extensions module.js:415
154 100.0% Function: Module.load module.js:333
65 25.3% LazyCompile: Join native array.js:100
65 100.0% LazyCompile: toString native array.js:361
65 100.0% LazyCompile: DefaultNumber native runtime.js:603
65 100.0% LazyCompile: NonNumberToNumber native runtime.js:514
65 100.0% LazyCompile: DIV native runtime.js:223
38 14.8% LazyCompile: Array.sum /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:39
38 100.0% LazyCompile: Array.ema /Users/Fredrick/Dropbox/Stackd/services/gauss/lib/vector.js:302
38 100.0% LazyCompile: <anonymous> /Users/Fredrick/Dropbox/Stackd/services/gauss/sandbox/ema.wilder.js:1
38 100.0% Function: Module._compile module.js:349
38 100.0% Function: Module._extensions module.js:415
167 3.1% Stub: NumberToString
167 100.0% LazyCompile: Join native array.js:100
167 100.0% LazyCompile: toString native array.js:361
167 100.0% LazyCompile: DefaultNumber native runtime.js:603
167 100.0% LazyCompile: NonNumberToNumber native runtime.js:514
167 100.0% LazyCompile: DIV native runtime.js:223
Successfully deleted temporary: profile-13264057338989582.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment