/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Haskell GHC program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
5000.300.30264403  0% 3% 3% 100%
3,00010.4510.462,244403  0% 1% 1% 100%
5,50035.1035.123,512403  0% 1% 1% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read spectral-norm benchmark to see what this program should do.

 notes

The Glorious Glasgow Haskell Compilation System, version 7.8.2

 spectral-norm Haskell GHC #2 program source code

--
-- The Computer Language Benchmarks Game
-- http://benchmarksgame.alioth.debian.org/
-- Contributed by Greg Buchholz 

import Data.Array.Base
import System.Environment
import Numeric

main = do 
        [arg] <- getArgs
        let n = (read arg) - 1 
        let init = listArray (0,n) (repeat 1.0)
        let (v:u:rest) = drop 19 $ iterate (eval_AtA_times_u n) init
        let vBv = sum [(u!i)*(v!i) |i<-[0..n]]
        let vv  = sum [(v!i)*(v!i) |i<-[0..n]]
        putStrLn $ showFFloat (Just 9) (sqrt (vBv/vv)) ""

eval_AtA_times_u n u = eval_At_times_u n v
    where v = eval_A_times_u n u

eval_A x y = 1.0/((i+j)*(i+j+1)/2+i+1)
    where i = fromIntegral x
          j = fromIntegral y

eval_A_times_u :: Int -> UArray Int Double -> UArray Int Double
eval_A_times_u n u = unsafeAccumArray (+) 0 (0,n) 
                     [(i,(eval_A i j) * u!j)|i<-[0..n], j<-[0..n]]
   
eval_At_times_u :: Int -> UArray Int Double -> UArray Int Double
eval_At_times_u n u = unsafeAccumArray (+) 0 (0,n) 
                      [(i,(eval_A j i) * u!j)|i<-[0..n], j<-[0..n]]

 make, command-line, and program output logs

Thu, 17 Apr 2014 01:39:57 GMT

MAKE:
mv spectralnorm.ghc-2.ghc spectralnorm.ghc-2.hs
/usr/local/src/ghc-7.8.2/bin/ghc --make -fllvm -O2 -XBangPatterns -rtsopts -XMagicHash -fexcess-precision spectralnorm.ghc-2.hs -o spectralnorm.ghc-2.ghc_run
[1 of 1] Compiling Main             ( spectralnorm.ghc-2.hs, spectralnorm.ghc-2.o )
Linking spectralnorm.ghc-2.ghc_run ...
rm spectralnorm.ghc-2.hs
1.87s to complete and log all make actions

COMMAND LINE:
./spectralnorm.ghc-2.ghc_run  5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play