-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Narrowing operations involving several cases can be quite slow. Using the test program:
import ceylon.ast.core {
Node
}
Anything slowness1(String|Node node)
=> if (is String node) then null else null;
//{ if (is String node) { return null; } else { return node; }
Anything slowness2(String|Node node)
=> if (is String node) then null else null;
//{ if (is String node) { return null; } else { return node; }
Anything slowness3(String|Node node)
=> if (is String node) then null else null;
//{ if (is String node) { return null; } else { return node; }
Anything slowness4(String|Node node)
=> if (is String node) then null else null;
//{ if (is String node) { return null; } else { return node; }
void load(Node n) {}
abstract class Foo() {}
abstract class Enum() of
A | B | C | D | E | F | G | H | I | J |
K | L | M | N | O | P | Q | R | S | T {}
class A() extends Enum() {} class B() extends Enum() {}
class C() extends Enum() {} class D() extends Enum() {}
class E() extends Enum() {} class F() extends Enum() {}
class G() extends Enum() {} class H() extends Enum() {}
class I() extends Enum() {} class J() extends Enum() {}
class K() extends Enum() {} class L() extends Enum() {}
class M() extends Enum() {} class N() extends Enum() {}
class O() extends Enum() {} class P() extends Enum() {}
class Q() extends Enum() {} class R() extends Enum() {}
class S() extends Enum() {} class T() extends Enum() {}I'm getting the following timings on my laptop:
slownessx(String|Node) (as shown above)
$ time ceylon compile-js --suppress-warning
Note: Created module simple/1.0.0
real 0m24.732s
user 0m32.355s
sys 0m0.610s
slownessx(String|Enum)
$ time ceylon compile-js --suppress-warning
Note: Created module simple/1.0.0
real 0m3.796s
user 0m9.294s
sys 0m0.295s
slownessx(String|Foo)
$ time ceylon compile-js --suppress-warning
Note: Created module simple/1.0.0
real 0m1.872s
user 0m4.039s
sys 0m0.232s
And with the slownessx functions commented out:
$ time ceylon compile-js --suppress-warning
Note: Created module simple/1.0.0
real 0m1.788s
user 0m3.924s
sys 0m0.226s
Reactions are currently unavailable