jweinst1
12/24/2016 - 8:05 AM

tsbenchmarktest.js

//compile time vs interpretive calling

    var LispVal = (function () {
        function LispVal(val) {
            if (val === void 0) { val = false; }
            this.val = val;
        }
        Object.defineProperty(LispVal.prototype, "getval", {
            get: function () { return this.val; },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(LispVal.prototype, "changeVal", {
            set: function (newval) { this.val = newval; },
            enumerable: true,
            configurable: true
        });
        return LispVal;
    }());
    var LispList = (function () {
        function LispList(items) {
            if (items === void 0) { items = []; }
            this.items = items;
        }
        //returns new item
        LispList.prototype.getAtIndex = function (index) {
            return this.items[Number(index.getval)];
        };
        LispList.pair = (function () {
            function class_1(first, next) {
                if (next === void 0) { next = new LispVal(); }
                this.first = first;
                this.next = next;
            }
            return class_1;
        }());
        return LispList;
    }());

var callobj = {
  "a":function(){
    return new LispList([new LispList.pair(4)]);
  }
};


console.time("interproute");
for(var j=0;j<100000;j++) if(3) callobj["a"]();
console.timeEnd("interproute");

/*interproute: 16ms*/