Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const suite = new (require("benchmark")).Suite;
- let a, b;
- const reset = () => { a = [1,2,3]; b = [4,5,6] }
- suite.add("Concat", function() {
- reset();
- a = a.concat(b);
- }).add("Push.apply", function() {
- reset();
- [].push.apply(a, b);
- }).add("Spread operator", function() {
- reset();
- a = [...a, ...b];
- }).on("cycle", function(event) {
- console.log(String(event.target));
- }).on("complete", function() {
- console.log("Fastest is " + this.filter("fastest").map("name"));
- }).run({ async: true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement