Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const suite = new (require("benchmark")).Suite;
  2.  
  3. let a, b;
  4.  
  5. const reset = () => { a = [1,2,3]; b = [4,5,6] }
  6.  
  7. suite.add("Concat", function() {
  8.     reset();
  9.  
  10.     a = a.concat(b);
  11. }).add("Push.apply", function() {
  12.     reset();
  13.  
  14.     [].push.apply(a, b);
  15. }).add("Spread operator", function() {
  16.     reset();
  17.  
  18.     a = [...a, ...b];
  19. }).on("cycle", function(event) {
  20.     console.log(String(event.target));
  21. }).on("complete", function() {
  22.     console.log("Fastest is " + this.filter("fastest").map("name"));
  23. }).run({ async: true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement