OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This benchmark is based on the six-speed benchmark build output. |
| 6 // Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/> |
| 7 |
| 8 'use strict'; |
| 9 |
| 10 new BenchmarkSuite('Babel', [1000], [ |
| 11 new Benchmark('Babel', false, false, 0, Babel), |
| 12 ]); |
| 13 |
| 14 var _get = function get(object, property, receiver) { |
| 15 if (object === null) object = Function.prototype; |
| 16 var desc = Object.getOwnPropertyDescriptor(object, property); |
| 17 if (desc === undefined) { |
| 18 var parent = Object.getPrototypeOf(object); |
| 19 if (parent === null) { |
| 20 return undefined; |
| 21 } else { |
| 22 return get(parent, property, receiver); |
| 23 } |
| 24 } else if ('value' in desc) { |
| 25 return desc.value; |
| 26 } else { |
| 27 var getter = desc.get; |
| 28 if (getter === undefined) { |
| 29 return undefined; |
| 30 } |
| 31 return getter.call(receiver); |
| 32 } |
| 33 }; |
| 34 |
| 35 var _createClass = function() { |
| 36 function defineProperties(target, props) { |
| 37 for (var i = 0; i < props.length; i++) { |
| 38 var descriptor = props[i]; |
| 39 descriptor.enumerable = descriptor.enumerable || false; |
| 40 descriptor.configurable = true; |
| 41 if ('value' in descriptor) descriptor.writable = true; |
| 42 Object.defineProperty(target, descriptor.key, descriptor); |
| 43 } |
| 44 } |
| 45 return function(Constructor, protoProps, staticProps) { |
| 46 if (protoProps) defineProperties(Constructor.prototype, protoProps); |
| 47 if (staticProps) defineProperties(Constructor, staticProps); |
| 48 return Constructor; |
| 49 }; |
| 50 }(); |
| 51 |
| 52 function _possibleConstructorReturn(self, call) { |
| 53 if (!self) { |
| 54 throw new ReferenceError( |
| 55 'this hasn\'t been initialised - super() hasn\'t been called'); |
| 56 } |
| 57 return call && (typeof call === 'object' || typeof call === 'function') ? |
| 58 call : |
| 59 self; |
| 60 } |
| 61 |
| 62 function _inherits(subClass, superClass) { |
| 63 if (typeof superClass !== 'function' && superClass !== null) { |
| 64 throw new TypeError( |
| 65 'Super expression must either be null or a function, not ' + |
| 66 typeof superClass); |
| 67 } |
| 68 subClass.prototype = Object.create(superClass && superClass.prototype, { |
| 69 constructor: { |
| 70 value: subClass, |
| 71 enumerable: false, |
| 72 writable: true, |
| 73 configurable: true |
| 74 } |
| 75 }); |
| 76 if (superClass) |
| 77 Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : |
| 78 subClass.__proto__ = superClass; |
| 79 } |
| 80 |
| 81 function _classCallCheck(instance, Constructor) { |
| 82 if (!(instance instanceof Constructor)) { |
| 83 throw new TypeError('Cannot call a class as a function'); |
| 84 } |
| 85 } |
| 86 |
| 87 var C = function() { |
| 88 function C() { |
| 89 _classCallCheck(this, C); |
| 90 |
| 91 this.foo = 'bar'; |
| 92 } |
| 93 |
| 94 _createClass(C, [{ |
| 95 key: 'bar', |
| 96 value: function bar() { |
| 97 return 41; |
| 98 } |
| 99 }]); |
| 100 |
| 101 return C; |
| 102 }(); |
| 103 |
| 104 var D = function(_C) { |
| 105 _inherits(D, _C); |
| 106 |
| 107 function D() { |
| 108 _classCallCheck(this, D); |
| 109 |
| 110 var _this = _possibleConstructorReturn( |
| 111 this, (D.__proto__ || Object.getPrototypeOf(D)).call(this)); |
| 112 |
| 113 _this.baz = 'bat'; |
| 114 return _this; |
| 115 } |
| 116 |
| 117 _createClass(D, [{ |
| 118 key: 'bar', |
| 119 value: function bar() { |
| 120 return _get( |
| 121 D.prototype.__proto__ || |
| 122 Object.getPrototypeOf(D.prototype), |
| 123 'bar', this) |
| 124 .call(this) + |
| 125 1; |
| 126 } |
| 127 }]); |
| 128 |
| 129 return D; |
| 130 }(C); |
| 131 |
| 132 function Babel() { |
| 133 var d = new D(); |
| 134 return d.bar(); |
| 135 } |
OLD | NEW |