uCBQN/test/cases/perf.bqn
2023-07-28 13:59:25 +03:00

42 lines
2.0 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%DEF var V•internal.Variation LV•internal.ListVariations CLR•internal.ClearRefs
%DEF tvar2 %USE var _tvar2_ {F _𝕣_ 𝕘 x: (CLR@) {F 𝕩 V x}¨ 𝕘 LV 𝕩; w F _𝕣_ 𝕘 x: (CLR@) (𝕘 LV 𝕨) {(𝕨 V w) F 𝕩 V x} 𝕘 LV 𝕩}
%DEF fastone (
_fastone { F _𝕣 𝕩:
t 0
n 𝕩
@F¨ n
{ 𝕊:
c F•_timed @
"wasn't fast enough" ! (n<10) t<5
t+ c
n+ 1
c10000e¯9
}•_while_ 1
n
}
)
# in-place ⌾(n⊸⊑)
(
%USE fastone
{ 𝕊 toti:
ab to•internal.Variation 10 < ti•internal.Variation 1e6
n {𝕊: a 10+(4)(1) } _fastone 10
! (4+10×n) 41a
}¨ "Ah""Ai32", "Af""Ai32", "Sh""Ai32", "Sf""Ai32", "Ah""Ah"
)
# in-place ⌾⊑
%USE fastone a5+1e6 n{𝕊: a 1+}_fastone 4 ! (10a) (5+n)6+9
# in-place ⌾(l⊸⊏)
%USE fastone a5+1e6 n{𝕊: a 1+(133¯1)}_fastone 4 ! (5678910000001000001100000210000031000004+0n0n00000n) (5a)¯5a #%NDEBUG
# in-place ∾⟜atom & ∾⟜list
%USE fastone %USE tvar2 {𝕊v: j<(×) v {a𝕩 n{𝕊: aj}_fastone 4 !( n +𝕩)a !av¨a}_tvar2_"f" 1e6 <𝕩}¨ 1, 12, 'a'
%USE fastone %USE tvar2 {𝕊v: j10<v {a𝕩 n{𝕊: aj}_fastone 4 !((10×n)+𝕩)a !av¨a}_tvar2_"f" 1e6 <𝕩}¨ 1, 12, 'a'
%USE fastone %USE tvar2 {𝕊v: j10<v {a𝕩 n{𝕊: aj}_fastone 4 !(10˜ n+𝕩)a !av¨a}_tvar2_"f" 1e510<𝕩}¨ 1, 12, 'a'
# amortized fast ⍋ with long 𝕨 & tiny 𝕩
%USE fastone %USE tvar2 (1e6/10) {𝕨𝕩 _fastone 1} _tvar2_"f" 10