Skip to content

Some test results are suspect. #71

@richardspence

Description

@richardspence

I noticed the destructuring tests for TS indicated 150X slower times than es5.

This is unusual because the emitted code is actually (almost) identical to the es5. The only difference is one additional variable declaration / assignment.

Emitted ts code for test: http://www.typescriptlang.org/play/index.html#src=var%20data%20%3D%20%7B%0D%0A%20%20a%3A%20'foo'%2C%0D%0A%20%20b%3A%20%7Bc%3A%20'd'%7D%2C%0D%0A%20%20arr%3A%20%5B1%2C%202%2C%203%5D%0D%0A%7D%3B%0D%0A%0D%0Afunction%20fn()%20%7B%0D%0A%20%20var%20%7Ba%2C%20b%3A%7Bc%3Ab%7D%2C%20arr%3A%5B%2C%20c%5D%7D%20%3D%20data%3B%0D%0A%20%20return%20c%3B%0D%0A%7D%0D%0A%0D%0AassertEqual(fn()%2C%202)%3B%0D%0Atest(fn)%3B

es5 test:

//emitted js from TS compiler
var data = {
    a: 'foo',
    b: { c: 'd' },
    arr: [1, 2, 3]
};
function fn() {
    var a = data.a, b = data.b.c, _a = data.arr, c = _a[1];
    return c;
}
assertEqual(fn(), 2);
test(fn);
//baseline es5
var data = {
  a: 'foo',
  b: {c: 'd'},
  arr: [1, 2, 3]
};

function fn() {
  var a = data.a,
      b = data.b.c,
      c = data.arr[1];
  return c;
}

assertEqual(fn(), 2);
test(fn);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions