Skip to content

sort is 645x slower after compilation #289

Description

@krissrex

Test script hello.ts:

const res: number[] = [];
for (let i = 0; i < 100000; i++) {
	res.push(i*-2);
}

res.sort((a, b) => a - b);

Execution time:

> time ./hello

________________________________________________________
Executed in   47.84 secs    fish           external
   usr time   47.22 secs    0.26 millis   47.22 secs
   sys time    0.13 secs    1.14 millis    0.13 secs
> time node hello.ts

________________________________________________________
Executed in   74.17 millis    fish           external
   usr time   61.70 millis    0.33 millis   61.37 millis
   sys time   13.00 millis    2.34 millis   10.66 millis

The big culprit is sort. Removing the line shaves of most of the time down to sub 1 second.


scriptc 0.0.32
node 22.21.1
Apple M4 Max

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions