https://wiki.haskell.org/index.php?title=Shootout/Random&feed=atom&action=history
Shootout/Random - Revision history
2024-03-19T04:39:47Z
Revision history for this page on the wiki
MediaWiki 1.35.5
https://wiki.haskell.org/index.php?title=Shootout/Random&diff=6706&oldid=prev
DonStewart at 02:19, 8 October 2006
2006-10-08T02:19:15Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 02:19, 8 October 2006</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"></td>
<td colspan="2" class="diff-empty"> </td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A Shootout Entry for the [http://shootout.alioth.debian.org/debian/benchmark.php?test=random&lang=all random benchmark].</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A Shootout Entry for the [http://shootout.alioth.debian.org/debian/benchmark.php?test=random&lang=all random benchmark].</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">Line 77:</td>
<td colspan="2" class="diff-lineno">Line 76:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ic = 29573</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> ic = 29573</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Code]]</div></td>
</tr>
<!-- diff cache key wikidb_haskell:diff:wikidiff2:1.12:old-6704:rev-6706:1.10.0 -->
</table>
DonStewart
https://wiki.haskell.org/index.php?title=Shootout/Random&diff=6704&oldid=prev
DonStewart: moved
2006-10-08T02:18:37Z
<p>moved</p>
<p><b>New page</b></p><div><br />
A Shootout Entry for the [http://shootout.alioth.debian.org/debian/benchmark.php?test=random&lang=all random benchmark].<br />
<br />
== Current entry ==<br />
<br />
Using `rem` (as the Clean entry does) halves running time on Linux/p4 (!)<br />
and about 10% faster on OpenBSD.<br />
<br />
''I see the same effect, or greater (!), on my powerbook with those compile options.<br />
Are you gong to submit this?'' -- ChrisKuklewicz<br />
<br />
''This has been submitted, however only a minor speedup occured on the gp4 test machine. Sigh. -- Dons''<br />
<br />
<haskell><br />
-- $Id: random-ghc.code,v 1.28 2006/01/08 23:33:35 igouy-guest Exp $<br />
-- http://shootout.alioth.debian.org<br />
--<br />
-- Original by Simon Marlow<br />
-- Heavily modified by Einar Karttunen, further by Don Stewart<br />
--<br />
-- ghc -o c C.hs -O3 -optc-O3 -fexcess-precision -fglasgow-exts <br />
--<br />
<br />
import System; import Numeric<br />
<br />
main = putStrLn . (\n -> showFFloat (Just 9) (randl (n-1) 42) []) . read . head =<< getArgs<br />
<br />
randl (n::Int) (seed::Int) = if n == 0 then nr else randl (n-1) ns :: Double<br />
where (ns,nr) = ((seed * ia + ic) `rem` im, 100 * (fromIntegral ns) / fromIntegral im)<br />
(im,ia,ic) = (139968,3877,29573)<br />
</haskell><br />
<br />
== Current entry ==<br />
<br />
Shortest entry in any language<br />
<br />
<haskell><br />
{-# OPTIONS -fglasgow-exts -O2 -optc-O3 #-}<br />
-- $Id: random-ghc.code,v 1.28 2006/01/08 23:33:35 igouy-guest Exp $<br />
-- http://shootout.alioth.debian.org<br />
--<br />
-- Original by Simon Marlow<br />
-- Heavily modified by Einar Karttunen and Don Stewart<br />
<br />
import System; import Numeric<br />
<br />
main = putStrLn . (\n -> showFFloat (Just 9) (randl (n-1) 42) []) . read . head =<< getArgs<br />
<br />
randl (n::Int) (seed::Int) = if n == 0 then nr else randl (n-1) ns :: Double<br />
where (ns,nr) = ((seed * ia + ic) `mod` im, (fromIntegral ns) * (100 / fromIntegral im))<br />
(im,ia,ic) = (139968,3877,29573)<br />
</haskell><br />
<br />
== Older entry ==<br />
<br />
<haskell><br />
{-# OPTIONS -O3 #-}<br />
-- $Id: random-ghc.code,v 1.28 2006/01/08 23:33:35 igouy-guest Exp $<br />
-- http://shootout.alioth.debian.org<br />
--<br />
-- Original by Simon Marlow<br />
-- Heavily modified by Einar Karttunen<br />
<br />
import System(getArgs)<br />
import Numeric(showFFloat)<br />
<br />
main = do ~[n] <- getArgs<br />
putStrLn (showFFloat (Just 9) (randl 100 ((read n)-1) 42) "")<br />
<br />
randl :: Double -> Int -> Int -> Double<br />
randl max n seed = newseed `seq` newrand `seq`<br />
if n == 0 then newrand else randl max (n-1) newseed<br />
where newseed = (seed * ia + ic) `mod` im<br />
newrand = (fromIntegral newseed) * (max / fromIntegral im)<br />
im = 139968<br />
ia = 3877<br />
ic = 29573<br />
</haskell></div>
DonStewart