Skip to content

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
@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