Last active
August 21, 2017 21:29
-
-
Save cybercussion/97fdf75b8411c5d528b033114e35d73f to your computer and use it in GitHub Desktop.
Revisions
-
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,8 +72,8 @@ //console.log(result2); }); suite.add("function extend3(obj1, obj2) {", function () { function extend3(obj1, obj2) { for (var p in obj2) { try { @@ -95,7 +95,7 @@ return obj1; } var result3 = extend3(defaults, settings); //console.log(result3); }); -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,8 +37,8 @@ }; suite.add("function extend1 () {", function () { function extend1 () { var i = 1, args = arguments, olen = args.length, -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 27 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,6 +72,33 @@ //console.log(result2); }); suite.add("function MergeRecursive(obj1, obj2) {", function () { function MergeRecursive(obj1, obj2) { for (var p in obj2) { try { // Property in destination object set; update its value. if ( obj2[p].constructor==Object ) { obj1[p] = MergeRecursive(obj1[p], obj2[p]); } else { obj1[p] = obj2[p]; } } catch(e) { // Property in destination object not set; create it and set its value. obj1[p] = obj2[p]; } } return obj1; } var result3 = MergeRecursive(defaults, settings); //console.log(result3); }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 6 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,9 +9,7 @@ })(function (Benchmark) { var suite = new Benchmark.Suite; Benchmark.prototype.setup = function () { var defaults = { version: "4.1.6", createDate: "04/05/2011 08:56AM", @@ -36,6 +34,10 @@ use_standalone: false, time_type: "GMT" }; }; suite.add("function extend1 (o) {", function () { function extend1 (o) { var i = 1, args = arguments, @@ -55,31 +57,7 @@ //console.log(result1); }); suite.add("function extend2 (to, from) {", function () { function extend2 (to, from) { for (n in from) { if (typeof to[n] != 'object') { -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,6 @@ use_standalone: false, time_type: "GMT" }; function extend1 (o) { var i = 1, args = arguments, -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,7 @@ return args[0]; } var result1 = extend1(defaults, settings); //console.log(result1); }); suite.add("var defaults = {", function () { @@ -92,11 +92,7 @@ return to; } var result2 = extend2(defaults, settings); //console.log(result2); }); suite.on("cycle", function (evt) { -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,7 @@ } return args[0]; } var result1 = extend1(defaults, settings); console.log(result1); }); @@ -91,7 +91,7 @@ } return to; } var result2 = extend2(defaults, settings); console.log(result2); }); -
cybercussion revised this gist
Aug 21, 2017 . 1 changed file with 33 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,6 +52,35 @@ } return args[0]; } var result1 = extend1(settings, options); console.log(result1); }); suite.add("var defaults = {", function () { var defaults = { version: "4.1.6", createDate: "04/05/2011 08:56AM", modifiedDate: "03/04/2016 12:24AM", debug: false, isActive: false, throw_alerts: false, preferred_API: "findAPI", // findAPI, findSCORM12, findSCORM2004 prefix: "SCOBotBase", exit_type: "suspend", // suspend, finish, or "" (undetermined) success_status: "unknown", // passed, failed, unknown use_standalone: true, // false if you don't want it to fail over locally standalone: false, // flag completion_status: "incomplete", // default completed, incomplete, unknown time_type: "UTC", // See GMT (pre 1972) vs UTC (post 1972) Time http://www.timeanddate.com/time/gmt-utc-time.html cmi: null, latency_arr: [] }, settings = { exit_type: "finish", success_status: "success", use_standalone: false, time_type: "GMT" }; function extend2 (to, from) { for (n in from) { if (typeof to[n] != 'object') { @@ -62,18 +91,14 @@ } return to; } var result2 = extend2(settings, options); console.log(result2); }); suite.add("", function () { }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); -
cybercussion revised this gist
Aug 21, 2017 . 2 changed files with 28 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"/> <title>Merge Test #jsbench #jsperf</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> <script src="./suite.js"></script> </head> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,27 +38,42 @@ }; function extend1 (o) { var i = 1, args = arguments, olen = args.length, key; while (i < olen) { for (key in args[i]) { if (args[i].hasOwnProperty(key)) { args[0][key] = args[i][key]; } } i += 1; } return args[0]; } function extend2 (to, from) { for (n in from) { if (typeof to[n] != 'object') { to[n] = from[n]; } else if (typeof from[n] == 'object') { to[n] = extend2(to[n], from[n]); } } return to; } }); suite.add("var result1 = extend1(settings, options);", function () { var result1 = extend1(settings, options); console.log(result1); }); suite.add("var result2 = extend2(settings, options);", function () { var result2 = extend2(settings, options); console.log(result2); }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); @@ -75,7 +90,7 @@ }); }); console.log("Merge Test #jsbench #jsperf"); console.log(new Array(30).join("-")); suite.run(); }); -
cybercussion created this gist
Aug 21, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Merge Test</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> <script src="./suite.js"></script> </head> <body> <h1>Open the console to view the results</h1> <h2><code>cmd + alt + j</code> or <code>ctrl + alt + j</code></h2> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ "use strict"; (function (factory) { if (typeof Benchmark !== "undefined") { factory(Benchmark); } else { factory(require("benchmark")); } })(function (Benchmark) { var suite = new Benchmark.Suite; suite.add("var defaults = {", function () { var defaults = { version: "4.1.6", createDate: "04/05/2011 08:56AM", modifiedDate: "03/04/2016 12:24AM", debug: false, isActive: false, throw_alerts: false, preferred_API: "findAPI", // findAPI, findSCORM12, findSCORM2004 prefix: "SCOBotBase", exit_type: "suspend", // suspend, finish, or "" (undetermined) success_status: "unknown", // passed, failed, unknown use_standalone: true, // false if you don't want it to fail over locally standalone: false, // flag completion_status: "incomplete", // default completed, incomplete, unknown time_type: "UTC", // See GMT (pre 1972) vs UTC (post 1972) Time http://www.timeanddate.com/time/gmt-utc-time.html cmi: null, latency_arr: [] }, settings = { exit_type: "finish", success_status: "success", use_standalone: false, time_type: "GMT" }; function extend1 (o) { var i = 1, args = arguments, olen = args.length, key; while (i < olen) { for (key in args[i]) { if (args[i].hasOwnProperty(key)) { args[0][key] = args[i][key]; } } i += 1; } return args[0]; } }); suite.add("var result1 = extend1(settings, options);", function () { var result1 = extend1(settings, options); console.log(result1); }); suite.on("cycle", function (evt) { console.log(" - " + evt.target); }); suite.on("complete", function (evt) { console.log(new Array(30).join("-")); var results = evt.currentTarget.sort(function (a, b) { return b.hz - a.hz; }); results.forEach(function (item) { console.log((idx + 1) + ". " + item); }); }); console.log("Merge Test"); console.log(new Array(30).join("-")); suite.run(); });