Skip to content

Instantly share code, notes, and snippets.

@andre487
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save andre487/3bdf64844213c6307595 to your computer and use it in GitHub Desktop.

Select an option

Save andre487/3bdf64844213c6307595 to your computer and use it in GitHub Desktop.
Sorting profiling
var fs = require('fs'),
profiler = require('v8-profiler'),
runSelectionSort = require('./selection-sort'),
runMergeSort = require('./merge-sort');
profiler.startProfiling('sort-app');
console.time('selection sort');
runSelectionSort();
console.timeEnd('selection sort');
console.time('merge sort');
runMergeSort();
console.timeEnd('merge sort');
var data = profiler.stopProfiling('sort-app');
fs.writeFile('app.cpuprofile', JSON.stringify(data));
{"typeId":"CPU","uid":1,"title":"sort-app","head":{"functionName":"(root)","url":"","lineNumber":0,"callUID":4224524906,"bailoutReason":"","id":1,"scriptId":0,"hitCount":0,"children":[{"functionName":"","url":"node.js","lineNumber":27,"callUID":4290622080,"bailoutReason":"no reason","id":2,"scriptId":26,"hitCount":0,"children":[{"functionName":"startup","url":"node.js","lineNumber":30,"callUID":3011772330,"bailoutReason":"no reason","id":3,"scriptId":26,"hitCount":0,"children":[{"functionName":"Module.runMain","url":"module.js","lineNumber":499,"callUID":3124799508,"bailoutReason":"no reason","id":4,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._load","url":"module.js","lineNumber":273,"callUID":3203251955,"bailoutReason":"TryFinallyStatement","id":5,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module.load","url":"module.js","lineNumber":345,"callUID":3528272629,"bailoutReason":"no reason","id":6,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._extensions..js","url":"module.js","lineNumber":476,"callUID":3755367272,"bailoutReason":"no reason","id":7,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._compile","url":"module.js","lineNumber":378,"callUID":3808196443,"bailoutReason":"no reason","id":8,"scriptId":31,"hitCount":0,"children":[{"functionName":"","url":"/Users/andre487/IdeaProjects/js-performance/sorting/app.js","lineNumber":1,"callUID":3416877639,"bailoutReason":"no reason","id":9,"scriptId":42,"hitCount":2,"children":[{"functionName":"profiler.startProfiling","url":"/Users/andre487/node_modules/v8-profiler/v8-profiler.js","lineNumber":113,"callUID":528942355,"bailoutReason":"no reason","id":10,"scriptId":43,"hitCount":1,"children":[]},{"functionName":"","url":"node.js","lineNumber":213,"callUID":1493043814,"bailoutReason":"no reason","id":11,"scriptId":26,"hitCount":0,"children":[{"functionName":"NativeModule.require","url":"node.js","lineNumber":755,"callUID":1942819575,"bailoutReason":"no reason","id":12,"scriptId":26,"hitCount":0,"children":[{"functionName":"NativeModule.compile","url":"node.js","lineNumber":800,"callUID":3309539828,"bailoutReason":"no reason","id":13,"scriptId":26,"hitCount":0,"children":[{"functionName":"","url":"console.js","lineNumber":1,"callUID":3493023732,"bailoutReason":"no reason","id":14,"scriptId":92,"hitCount":0,"children":[{"functionName":"","url":"node.js","lineNumber":500,"callUID":266895698,"bailoutReason":"no reason","id":15,"scriptId":26,"hitCount":0,"children":[{"functionName":"createWritableStdioStream","url":"node.js","lineNumber":435,"callUID":2560448168,"bailoutReason":"no reason","id":16,"scriptId":26,"hitCount":0,"children":[{"functionName":"WriteStream","url":"tty.js","lineNumber":73,"callUID":289638575,"bailoutReason":"no reason","id":17,"scriptId":86,"hitCount":0,"children":[{"functionName":"Socket","url":"net.js","lineNumber":137,"callUID":3804262993,"bailoutReason":"no reason","id":18,"scriptId":67,"hitCount":0,"children":[{"functionName":"Duplex","url":"_stream_duplex.js","lineNumber":41,"callUID":870115782,"bailoutReason":"no reason","id":19,"scriptId":38,"hitCount":1,"children":[{"functionName":"Writable","url":"_stream_writable.js","lineNumber":146,"callUID":2220548517,"bailoutReason":"no reason","id":20,"scriptId":37,"hitCount":0,"children":[{"functionName":"WritableState","url":"_stream_writable.js","lineNumber":42,"callUID":3998342974,"bailoutReason":"no reason","id":21,"scriptId":37,"hitCount":1,"children":[]}]}]}]}]}]},{"functionName":"process.on.process.addListener","url":"node.js","lineNumber":647,"callUID":4144846797,"bailoutReason":"no reason","id":22,"scriptId":26,"hitCount":2,"children":[{"functionName":"addListener","url":"events.js","lineNumber":138,"callUID":599164762,"bailoutReason":"no reason","id":23,"scriptId":27,"hitCount":1,"children":[]}]}]},{"functionName":"Console","url":"console.js","lineNumber":24,"callUID":2813679586,"bailoutReason":"no reason","id":24,"scriptId":92,"hitCount":1,"children":[]}]}]}]}]},{"functionName":"runSelectionSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":1,"callUID":35553008,"bailoutReason":"no reason","id":25,"scriptId":90,"hitCount":1,"children":[{"functionName":"createCollection","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":10,"callUID":346981309,"bailoutReason":"no reason","id":26,"scriptId":90,"hitCount":4,"children":[]},{"functionName":"sort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":29,"callUID":4220066838,"bailoutReason":"no reason","id":27,"scriptId":90,"hitCount":2,"children":[{"functionName":"swap","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":50,"callUID":2713893259,"bailoutReason":"no reason","id":28,"scriptId":90,"hitCount":1,"children":[]},{"functionName":"findMin","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":40,"callUID":3068790731,"bailoutReason":"no reason","id":29,"scriptId":90,"hitCount":113,"children":[]}]},{"functionName":"Console.log","url":"console.js","lineNumber":54,"callUID":2999047633,"bailoutReason":"no reason","id":30,"scriptId":92,"hitCount":0,"children":[{"functionName":"Socket.write","url":"net.js","lineNumber":621,"callUID":2833865771,"bailoutReason":"no reason","id":31,"scriptId":67,"hitCount":0,"children":[{"functionName":"Writable.write","url":"_stream_writable.js","lineNumber":196,"callUID":2339558733,"bailoutReason":"no reason","id":32,"scriptId":37,"hitCount":0,"children":[{"functionName":"writeOrBuffer","url":"_stream_writable.js","lineNumber":265,"callUID":1375716080,"bailoutReason":"no reason","id":33,"scriptId":37,"hitCount":0,"children":[{"functionName":"doWrite","url":"_stream_writable.js","lineNumber":293,"callUID":4073696911,"bailoutReason":"no reason","id":34,"scriptId":37,"hitCount":0,"children":[{"functionName":"Socket._write","url":"net.js","lineNumber":699,"callUID":3845286951,"bailoutReason":"no reason","id":35,"scriptId":67,"hitCount":0,"children":[{"functionName":"Socket._writeGeneric","url":"net.js","lineNumber":629,"callUID":205533425,"bailoutReason":"no reason","id":36,"scriptId":67,"hitCount":0,"children":[{"functionName":"createWriteReq","url":"net.js","lineNumber":703,"callUID":3188056091,"bailoutReason":"no reason","id":37,"scriptId":67,"hitCount":0,"children":[{"functionName":"writeUtf8String","url":"","lineNumber":0,"callUID":580253407,"bailoutReason":"","id":38,"scriptId":0,"hitCount":1,"children":[]}]}]}]}]}]}]}]}]}]},{"functionName":"Console.timeEnd","url":"console.js","lineNumber":82,"callUID":1513946817,"bailoutReason":"no reason","id":39,"scriptId":92,"hitCount":0,"children":[{"functionName":"Console.log","url":"console.js","lineNumber":54,"callUID":2999047633,"bailoutReason":"no reason","id":40,"scriptId":92,"hitCount":0,"children":[{"functionName":"Socket.write","url":"net.js","lineNumber":621,"callUID":2833865771,"bailoutReason":"no reason","id":41,"scriptId":67,"hitCount":0,"children":[{"functionName":"Writable.write","url":"_stream_writable.js","lineNumber":196,"callUID":2339558733,"bailoutReason":"no reason","id":42,"scriptId":37,"hitCount":0,"children":[{"functionName":"writeOrBuffer","url":"_stream_writable.js","lineNumber":265,"callUID":1375716080,"bailoutReason":"no reason","id":43,"scriptId":37,"hitCount":0,"children":[{"functionName":"doWrite","url":"_stream_writable.js","lineNumber":293,"callUID":4073696911,"bailoutReason":"no reason","id":44,"scriptId":37,"hitCount":0,"children":[{"functionName":"Socket._write","url":"net.js","lineNumber":699,"callUID":3845286951,"bailoutReason":"no reason","id":45,"scriptId":67,"hitCount":0,"children":[{"functionName":"Socket._writeGeneric","url":"net.js","lineNumber":629,"callUID":205533425,"bailoutReason":"no reason","id":46,"scriptId":67,"hitCount":1,"children":[]}]}]}]}]}]},{"functionName":"exports.format","url":"util.js","lineNumber":23,"callUID":3408105752,"bailoutReason":"no reason","id":113,"scriptId":28,"hitCount":1,"children":[]}]}]},{"functionName":"runMergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":1,"callUID":1309413297,"bailoutReason":"no reason","id":48,"scriptId":91,"hitCount":0,"children":[{"functionName":"createCollection","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":10,"callUID":1756120290,"bailoutReason":"no reason","id":49,"scriptId":91,"hitCount":3,"children":[]},{"functionName":"sort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":29,"callUID":3891012699,"bailoutReason":"no reason","id":50,"scriptId":91,"hitCount":2,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":51,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":52,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":53,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":54,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":55,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":56,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":57,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":58,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":59,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":60,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":61,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":62,"scriptId":91,"hitCount":0,"children":[{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":63,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":64,"scriptId":91,"hitCount":4,"children":[]}]},{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":65,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":66,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":67,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":68,"scriptId":91,"hitCount":4,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":69,"scriptId":91,"hitCount":6,"children":[{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":70,"scriptId":91,"hitCount":4,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":78,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":1701530029,"bailoutReason":"no reason","id":105,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":243083541,"bailoutReason":"no reason","id":99,"scriptId":91,"hitCount":1,"children":[]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":87,"scriptId":91,"hitCount":2,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":91,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":73,"scriptId":91,"hitCount":2,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":74,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":106,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":71,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":72,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":101,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":75,"scriptId":91,"hitCount":2,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":76,"scriptId":91,"hitCount":3,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":77,"scriptId":91,"hitCount":2,"children":[]},{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":1701530029,"bailoutReason":"no reason","id":108,"scriptId":91,"hitCount":1,"children":[]}]},{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":84,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":85,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":86,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":88,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":98,"scriptId":91,"hitCount":1,"children":[]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":107,"scriptId":91,"hitCount":1,"children":[]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":79,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":80,"scriptId":91,"hitCount":3,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":81,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":92,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":94,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":102,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":93,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":95,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":89,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":90,"scriptId":91,"hitCount":4,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":82,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":83,"scriptId":91,"hitCount":4,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":1988696391,"bailoutReason":"no reason","id":100,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":96,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":103,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":1701530029,"bailoutReason":"no reason","id":104,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":97,"scriptId":91,"hitCount":3,"children":[]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":285407318,"bailoutReason":"no reason","id":109,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":2615125736,"bailoutReason":"no reason","id":110,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":1701530029,"bailoutReason":"no reason","id":111,"scriptId":91,"hitCount":3,"children":[]}]}]}]}]},{"functionName":"isSorted","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":19,"callUID":3567817164,"bailoutReason":"no reason","id":112,"scriptId":91,"hitCount":1,"children":[]}]}]}]}]}]}]}]}]}]},{"functionName":"(garbage collector)","url":"","lineNumber":0,"callUID":89728452,"bailoutReason":"","id":47,"scriptId":0,"hitCount":12,"children":[]}]},"startTime":257001,"endTime":257001,"samples":[10,19,21,22,22,23,24,9,9,26,26,26,26,28,27,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,27,29,29,29,29,29,29,29,29,29,25,38,46,47,47,47,49,49,49,50,50,47,64,70,47,47,60,72,74,77,78,81,80,64,78,80,83,84,86,76,87,88,69,69,47,47,47,73,83,53,75,58,80,90,91,69,92,69,68,76,67,90,69,70,93,94,47,95,83,96,52,97,85,98,87,75,99,86,100,101,102,77,90,73,68,104,47,68,105,70,70,71,106,68,69,74,64,107,76,108,64,90,83,97,97,110,111,111,111,110,47,112,113]}
{"typeId":"CPU","uid":1,"title":"sort-app","head":{"functionName":"(root)","url":"","lineNumber":0,"callUID":1623878690,"bailoutReason":"","id":1,"scriptId":0,"hitCount":0,"children":[{"functionName":"","url":"node.js","lineNumber":27,"callUID":4290622080,"bailoutReason":"no reason","id":2,"scriptId":26,"hitCount":0,"children":[{"functionName":"startup","url":"node.js","lineNumber":30,"callUID":3011772330,"bailoutReason":"no reason","id":3,"scriptId":26,"hitCount":0,"children":[{"functionName":"Module.runMain","url":"module.js","lineNumber":499,"callUID":3124799508,"bailoutReason":"no reason","id":4,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._load","url":"module.js","lineNumber":273,"callUID":3203251955,"bailoutReason":"TryFinallyStatement","id":5,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module.load","url":"module.js","lineNumber":345,"callUID":3528272629,"bailoutReason":"no reason","id":6,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._extensions..js","url":"module.js","lineNumber":476,"callUID":3755367272,"bailoutReason":"no reason","id":7,"scriptId":31,"hitCount":0,"children":[{"functionName":"Module._compile","url":"module.js","lineNumber":378,"callUID":3808196443,"bailoutReason":"no reason","id":8,"scriptId":31,"hitCount":0,"children":[{"functionName":"","url":"/Users/andre487/IdeaProjects/js-performance/sorting/app.js","lineNumber":1,"callUID":2976236245,"bailoutReason":"no reason","id":9,"scriptId":42,"hitCount":1,"children":[{"functionName":"profiler.startProfiling","url":"/Users/andre487/node_modules/v8-profiler/v8-profiler.js","lineNumber":113,"callUID":218006887,"bailoutReason":"no reason","id":10,"scriptId":43,"hitCount":1,"children":[]},{"functionName":"","url":"node.js","lineNumber":213,"callUID":925378654,"bailoutReason":"no reason","id":11,"scriptId":26,"hitCount":0,"children":[{"functionName":"NativeModule.require","url":"node.js","lineNumber":755,"callUID":1942819575,"bailoutReason":"no reason","id":12,"scriptId":26,"hitCount":0,"children":[{"functionName":"NativeModule.compile","url":"node.js","lineNumber":800,"callUID":3309539828,"bailoutReason":"no reason","id":13,"scriptId":26,"hitCount":0,"children":[{"functionName":"runInThisContext","url":"node.js","lineNumber":740,"callUID":1569122627,"bailoutReason":"no reason","id":14,"scriptId":26,"hitCount":1,"children":[]},{"functionName":"","url":"console.js","lineNumber":1,"callUID":4221655712,"bailoutReason":"no reason","id":15,"scriptId":92,"hitCount":1,"children":[{"functionName":"","url":"node.js","lineNumber":500,"callUID":4144846797,"bailoutReason":"no reason","id":16,"scriptId":26,"hitCount":0,"children":[{"functionName":"createWritableStdioStream","url":"node.js","lineNumber":435,"callUID":2560448168,"bailoutReason":"no reason","id":17,"scriptId":26,"hitCount":0,"children":[{"functionName":"WriteStream","url":"tty.js","lineNumber":73,"callUID":938765934,"bailoutReason":"no reason","id":18,"scriptId":86,"hitCount":0,"children":[{"functionName":"Socket","url":"net.js","lineNumber":137,"callUID":709760303,"bailoutReason":"no reason","id":19,"scriptId":67,"hitCount":0,"children":[{"functionName":"Duplex","url":"_stream_duplex.js","lineNumber":41,"callUID":1383909991,"bailoutReason":"no reason","id":20,"scriptId":38,"hitCount":0,"children":[{"functionName":"Readable","url":"_stream_readable.js","lineNumber":99,"callUID":985763658,"bailoutReason":"no reason","id":21,"scriptId":36,"hitCount":0,"children":[{"functionName":"ReadableState","url":"_stream_readable.js","lineNumber":34,"callUID":4123149981,"bailoutReason":"no reason","id":22,"scriptId":36,"hitCount":1,"children":[]}]}]}]}]}]}]}]}]}]}]},{"functionName":"runSelectionSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":1,"callUID":346981309,"bailoutReason":"no reason","id":23,"scriptId":90,"hitCount":0,"children":[{"functionName":"createCollection","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":10,"callUID":4220066838,"bailoutReason":"no reason","id":24,"scriptId":90,"hitCount":1,"children":[]},{"functionName":"sort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":29,"callUID":3068790731,"bailoutReason":"no reason","id":25,"scriptId":90,"hitCount":2,"children":[{"functionName":"findMin","url":"/Users/andre487/IdeaProjects/js-performance/sorting/selection-sort.js","lineNumber":40,"callUID":2713893259,"bailoutReason":"no reason","id":26,"scriptId":90,"hitCount":77,"children":[]}]},{"functionName":"Console.log","url":"console.js","lineNumber":54,"callUID":2168870683,"bailoutReason":"no reason","id":27,"scriptId":92,"hitCount":0,"children":[{"functionName":"Socket.write","url":"net.js","lineNumber":630,"callUID":2339558733,"bailoutReason":"no reason","id":28,"scriptId":67,"hitCount":1,"children":[{"functionName":"Writable.write","url":"_stream_writable.js","lineNumber":196,"callUID":851495446,"bailoutReason":"no reason","id":29,"scriptId":37,"hitCount":0,"children":[{"functionName":"writeOrBuffer","url":"_stream_writable.js","lineNumber":265,"callUID":1280644128,"bailoutReason":"no reason","id":30,"scriptId":37,"hitCount":0,"children":[{"functionName":"doWrite","url":"_stream_writable.js","lineNumber":293,"callUID":3845286951,"bailoutReason":"no reason","id":31,"scriptId":37,"hitCount":0,"children":[{"functionName":"Socket._write","url":"net.js","lineNumber":708,"callUID":205533425,"bailoutReason":"no reason","id":32,"scriptId":67,"hitCount":0,"children":[{"functionName":"Socket._writeGeneric","url":"net.js","lineNumber":638,"callUID":2750852831,"bailoutReason":"no reason","id":33,"scriptId":67,"hitCount":0,"children":[{"functionName":"unrefTimer","url":"net.js","lineNumber":204,"callUID":3188056091,"bailoutReason":"no reason","id":34,"scriptId":67,"hitCount":0,"children":[{"functionName":"exports._unrefActive","url":"timers.js","lineNumber":546,"callUID":3445017646,"bailoutReason":"no reason","id":35,"scriptId":68,"hitCount":1,"children":[]}]}]}]}]}]}]}]}]}]},{"functionName":"runMergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":1,"callUID":3891012699,"bailoutReason":"no reason","id":36,"scriptId":91,"hitCount":0,"children":[{"functionName":"createCollection","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":10,"callUID":243083541,"bailoutReason":"no reason","id":37,"scriptId":91,"hitCount":2,"children":[]},{"functionName":"sort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":29,"callUID":285407318,"bailoutReason":"no reason","id":39,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":40,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":41,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":42,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":43,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":44,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":45,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":46,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":47,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":48,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":49,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":50,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":51,"scriptId":91,"hitCount":1,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":52,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":53,"scriptId":91,"hitCount":0,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":54,"scriptId":91,"hitCount":3,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":55,"scriptId":91,"hitCount":7,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":56,"scriptId":91,"hitCount":2,"children":[{"functionName":"mergeSort","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":36,"callUID":2615125736,"bailoutReason":"no reason","id":57,"scriptId":91,"hitCount":2,"children":[]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":58,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":59,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":60,"scriptId":91,"hitCount":2,"children":[]}]},{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":72,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":61,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":62,"scriptId":91,"hitCount":1,"children":[]},{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":101,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":102,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":83,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":84,"scriptId":91,"hitCount":3,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":63,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":64,"scriptId":91,"hitCount":1,"children":[]},{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":70,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":71,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":73,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":74,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":75,"scriptId":91,"hitCount":1,"children":[]},{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":104,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":65,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":66,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":67,"scriptId":91,"hitCount":1,"children":[]},{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":94,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":97,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":98,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":99,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":68,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":69,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":79,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":95,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":96,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":90,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":91,"scriptId":91,"hitCount":2,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":81,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":82,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":80,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":85,"scriptId":91,"hitCount":0,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":86,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":92,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":93,"scriptId":91,"hitCount":3,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":76,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":77,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":78,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":87,"scriptId":91,"hitCount":1,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":100,"scriptId":91,"hitCount":1,"children":[]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":88,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":89,"scriptId":91,"hitCount":2,"children":[{"functionName":"setFromRight","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":60,"callUID":3062226364,"bailoutReason":"no reason","id":105,"scriptId":91,"hitCount":1,"children":[]}]}]}]},{"functionName":"merge","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":49,"callUID":1988696391,"bailoutReason":"no reason","id":106,"scriptId":91,"hitCount":0,"children":[{"functionName":"setInRange","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":65,"callUID":1701530029,"bailoutReason":"no reason","id":107,"scriptId":91,"hitCount":1,"children":[{"functionName":"setFromLeft","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":55,"callUID":3567817164,"bailoutReason":"no reason","id":108,"scriptId":91,"hitCount":1,"children":[]}]}]}]}]},{"functionName":"isSorted","url":"/Users/andre487/IdeaProjects/js-performance/sorting/merge-sort.js","lineNumber":19,"callUID":3192466592,"bailoutReason":"no reason","id":109,"scriptId":91,"hitCount":1,"children":[]}]}]}]}]}]}]}]}]}]},{"functionName":"(garbage collector)","url":"","lineNumber":0,"callUID":3037899798,"bailoutReason":"","id":38,"scriptId":0,"hitCount":5,"children":[]},{"functionName":"(program)","url":"","lineNumber":0,"callUID":3381970737,"bailoutReason":"","id":103,"scriptId":0,"hitCount":1,"children":[]}]},"startTime":257178,"endTime":257178,"samples":[10,14,22,15,24,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,28,35,37,38,37,39,57,60,62,64,67,69,38,71,55,72,51,56,55,75,55,55,78,79,73,60,63,80,46,38,82,84,86,84,54,55,76,87,89,91,63,61,93,58,38,84,93,94,96,93,99,55,83,100,55,102,57,56,38,54,98,103,104,91,54,66,77,105,89,108,107,109,9]}
module.exports = function runMergeSort() {
var echo = typeof print == 'function' ? print : console.log.bind(console);
var collection = createCollection(),
sortedCollection = sort(collection);
echo('Sorted:', isSorted(sortedCollection) ? 'yes' : 'no');
};
// Создать коллекцию
function createCollection() {
var collection = new Array(1e5);
for (var i = 0; i < collection.length; i++) {
collection[i] = Math.random();
}
return collection;
}
// Проверка сортировки
function isSorted(collection) {
for (var i = 1; i < collection.length; i++) {
if (collection[i - 1] > collection[i]) {
return false;
}
}
return true;
}
// Сортировка слиянием
function sort(collection) {
var up = [].slice.call(collection),
length = up.length,
down = new Array(length);
return mergeSort(up, down, 0, length - 1);
}
function mergeSort(up, down, left, right) {
if (left >= right) {
down[left] = up[left];
return down;
}
var mid = Math.floor((left + right) / 2),
lColl = mergeSort(up, down, left, mid),
rColl = mergeSort(up, down, mid + 1, right);
return merge(up, down, lColl, rColl, left, right, mid);
}
function merge(up, down, lColl, rColl, left, right, mid) {
var target = lColl == up ? down : up;
var l = left,
r = mid + 1;
function setFromLeft(i) {
target[i] = lColl[l];
l++;
}
function setFromRight(i) {
target[i] = rColl[r];
r++;
}
function setInRange(i) {
if (lColl[l] < rColl[r]) {
setFromLeft(i);
} else {
setFromRight(i);
}
}
for (var i = left; i <= right; i++) {
if (l <= mid && r <= right) {
setInRange(i);
} else if (l <= mid) {
setFromLeft(i);
} else {
setFromRight(i);
}
}
return target;
}
module.exports = function runSelectionSort() {
var echo = typeof print == 'function' ? print : console.log.bind(console);
var collection = createCollection(),
sortedCollection = sort(collection);
echo('Sorted:', isSorted(sortedCollection) ? 'yes' : 'no');
};
// Создать коллекцию
function createCollection() {
var collection = new Array(1e4);
for (var i = 0; i < collection.length; i++) {
collection[i] = Math.random();
}
return collection;
}
// Проверка сортировки
function isSorted(collection) {
for (var i = 1; i < collection.length; i++) {
if (collection[i - 1] > collection[i]) {
return false;
}
}
return true;
}
// Сортировка выбором
function sort(collection) {
collection = [].slice.call(collection);
for (var i = 0; i < collection.length - 1; i++) {
var min = findMin(collection, i);
if (min != i) {
swap(collection, i, min);
}
}
return collection;
}
function findMin(collection, i) {
var min = i;
for (var j = min + 1; j < collection.length; j++) {
if (collection[j] < collection[min]) {
min = j;
}
}
return min;
}
function swap(collection, i, j) {
var tmp = collection[i];
collection[i] = collection[j];
collection[j] = tmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment