[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-apl] Slow Macros? (at svn 739)
From: |
Christian Robert |
Subject: |
Re: [Bug-apl] Slow Macros? (at svn 739) |
Date: |
Fri, 17 Jun 2016 01:01:29 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
I reverted to SVN 739 and did the test
address@hidden:/home/xtian] $ apl
______ _ __ __ __ ___ ____ __
/ ____// | / // / / / / | / __ \ / /
/ / __ / |/ // / / / / /| | / /_/ // /
/ /_/ // /| // /_/ / / ___ | / ____// /___
\____//_/ |_/ \____/ /_/ |_|/_/ /_____/
Welcome to GNU APL version 1.5 / 739
Copyright (C) 2008-2015 Dr. Jürgen Sauermann
Banner by FIGlet: www.figlet.org
This program comes with ABSOLUTELY NO WARRANTY;
for details run: apl --gpl.
This program is free software, and you are welcome to redistribute it
according to the GNU Public License (GPL) version 3 or later.
WARNING: this workspace was )SAVEd with SVN version 745
but is now being )LOADed with SVN version 739
Expect problems, in particular when the )SI was not clear.
In case of problems, please try )COPY instead of )LOAD.
SAVED 2016-06-16 22:35:45 (GMT-4)
)load Loto
WARNING: this workspace was )SAVEd with SVN version 745
but is now being )LOADed with SVN version 739
Expect problems, in particular when the )SI was not clear.
In case of problems, please try )COPY instead of )LOAD.
SAVED 2016-06-17 00:50:12 (GMT-4)
df
Freq ╔═══════════════════════╗
║z←Freq m;c ║
║z←⌈/,m ║
║c←z⍴0 ║
║⊣ {c[⍵]←c[⍵]+1}⍤0 ⊢ m ║
║z←⍉(2,z)⍴(⍳z),c ║
╚═══════════════════════╝
Loto ╔════════════════════════════════════════════╗
║z←n Loto x;y;⎕io ║
║⎕io←1 ◊(x y)←x ║
║z←{⍵[⍋⍵;]} {(⊂⍋⍵)⌷⍵}⍤1 ⊢ {x?y⊣⍵}⍤1 ⊢ (n,x)⍴0║
╚════════════════════════════════════════════╝
Randomize ╔═══════════════════════════╗
║Randomize ;fd ║
║fd ← ⎕fio[3] '/dev/urandom'║
║⎕rl←(7⍴256)⊥7 ⎕fio[41] fd ║
║⊣ ⎕fio[4] fd ║
╚═══════════════════════════╝
time ╔══════════════════════╗
║z←time cmd;start;stop ║
║start←⎕fio ¯1 ║
║⊣ ⍎cmd ║
║stop←⎕fio ¯1 ║
║z←(stop-start)÷⎕fio ¯2║
╚══════════════════════╝
time 'r←10000 Loto 6 49'
0.2002187493
time 'r←Freq 10000 Loto 6 49'
0.5909527821
time 'r←1000000 Loto 6 49'
13.35706916
time 'r←Freq 1000000 Loto 6 49'
40.89367723
Xtian.
On 2016-06-17 00:29, Christian Robert wrote:
⎕pw←1000
df
Freq ╔═══════════════════════╗
║z←Freq m;c ║
║z←⌈/,m ║
║c←z⍴0 ║
║⊣ {c[⍵]←c[⍵]+1}⍤0 ⊢ m ║
║z←⍉(2,z)⍴(⍳z),c ║
╚═══════════════════════╝
Loto ╔════════════════════════════════════════════╗
║z←n Loto x;y;⎕io ║
║⎕io←1 ◊(x y)←x ║
║z←{⍵[⍋⍵;]} {(⊂⍋⍵)⌷⍵}⍤1 ⊢ {x?y⊣⍵}⍤1 ⊢ (n,x)⍴0║
╚════════════════════════════════════════════╝
Randomize ╔═══════════════════════════╗
║Randomize ;fd ║
║fd ← ⎕fio[3] '/dev/urandom'║
║⎕rl←(7⍴256)⊥7 ⎕fio[41] fd ║
║⊣ ⎕fio[4] fd ║
╚═══════════════════════════╝
time ╔══════════════════════╗
║z←time cmd;start;stop ║
║start←⎕fio ¯1 ║
║⊣ ⍎cmd ║
║stop←⎕fio ¯1 ║
║z←(stop-start)÷⎕fio ¯2║
╚══════════════════════╝
time 'r←10000 Loto 6 49'
9.009529247
time 'r←Freq 10000 Loto 6 49'
40.7652658
⍝ I did it for 1,000,000 and pretty sure got the result within 2 minutes
*before* *macros*.
my 2 more cents,
Xtian.
- [Bug-apl] Slow Macros?, Christian Robert, 2016/06/17
- Re: [Bug-apl] Slow Macros? (at svn 739),
Christian Robert <=