Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arr.sortを非同期処理に変更 #633

Merged
merged 7 commits into from
May 12, 2024

Conversation

salano-ym
Copy link
Member

@salano-ym salano-ym commented Apr 23, 2024

What

arr.sortはマージソートで実装されており、分割した左右のソートを順番に実行しているが、これを非同期的に実行するようにした。

結果:arr.sortが高速化される。
8531ms -> 1858ms (Codespaces上で実行)

let a = Core:range(1,10000).map(@(){Math:rnd()})
let t1 = Date:now()
a.sort(@(x,y){x-y})
<: Date:now() - t1

Why

結構速くなる

Additional info (optional)

比較関数に副作用等がある場合に結果が変わる可能性がある。(そういうコードを書く人がいるかは不明)

@salano-ym salano-ym requested a review from uzmoi May 10, 2024 13:44
@salano-ym salano-ym merged commit 884bfeb into aiscript-dev:master May 12, 2024
4 checks passed
@salano-ym salano-ym deleted the async-mergesort branch May 12, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants