#1621: GHCi wrong execution time report
---------------------+------------------------------------------------------
 Reporter:  guest    |          Owner:                
     Type:  bug      |         Status:  new           
 Priority:  normal   |      Milestone:                
Component:  GHCi     |        Version:  6.6.1         
 Severity:  normal   |     Resolution:                
 Keywords:           |     Difficulty:  Unknown       
 Testcase:           |   Architecture:  x86_64 (amd64)
       Os:  Windows  |  
---------------------+------------------------------------------------------
Old description:

> Hello,
>
>   using latest GHC 6.6.1 binary package for windows, I've received
> strange information about execution time for the module below.
>
> My machine: OS WinXP Pro SP2, Intel Core 2, 2GB RAM.
>
> How to reproduce error:
>
> :set +s
> :set -02
> :cd <path to the file in the attachment>
> :l Primes
>
> Then running
> take 10000 primes1
> take 10000 primes2
> take 10000 primes3
> take 10000 primes1'
> take 10000 primes2'
> take 10000 primes3'
>
> Results seem to be correct, but the execution time reported no. First
> column is the GHCi report, the second column is th stop-watch data (just
> to correlate). No other task, except core windows, was running at the
> moment.
>
>   GHCi    Stop-watch
>  236.03     672.2
>   63.52      63.9
>   63.01      64.0
> 1098.75     671.0
> -365.07      65.2      // it's not a typo, really minus three hundred and
> sixty five
>   63.59      63.6
>
> Best regards,
>
>     Dusan
>
> ---------
> module Primes (
>           primes1
>          ,primes2
>          ,primes3
>          ,primes2'
>          ,primes3'
>        ) where
>

> candidates = map (\x -> (True,x)) [2..]
> candidates' =  [2..]
>
> skipmap f toSkip list = domap toSkip list
>   where
>     domap n (x:xs)
>       | n > 1  =  x : domap (n-1) xs
>       | True   =  f x : domap toSkip xs
>     domap _ [] = []
>
> primes1 = sieve candidates
>   where
>     sieve (pp@(isp,p):xs)
>       | isp  =  p : (sieve $ skipmap (\(_,v) -> (False,v)) p xs)
>       | True =  sieve xs
>
> primes1' = sieve candidates'
>   where
>     sieve (p:xs)
>       | p > 0  =  p : (sieve $ skipmap (\n -> if n>0 then (-n) else n) p
> xs)
>       | True   =  sieve xs
>

>
> sieve (p:xs) = p : sieve [y | y <- xs, y `mod` p /= 0]
> sieve' (p:xs) = p : sieve [y | y <- xs, y `mod` p > 0]
>
> primes2  = sieve [2..]
> primes3 = 2 : sieve [3,5..]
>
> primes2'  = sieve' [2..]
> primes3' = 2 : sieve' [3,5..]

New description:

 Hello,

 using latest GHC 6.6.1 binary package for windows, I've received strange
 information about execution time for the module below.

 My machine: OS WinXP Pro SP2, Intel Core 2, 2GB RAM.

 How to reproduce error:
 {{{
 :set +s
 :set -02
 :cd <path to the file in the attachment>
 :l Primes
 }}}

 Then running
 {{{
 take 10000 primes1
 take 10000 primes2
 take 10000 primes3
 take 10000 primes1'
 take 10000 primes2'
 take 10000 primes3'
 }}}

 Results seem to be correct, but the execution time reported no. First
 column is the GHCi report, the second column is th stop-watch data (just
 to correlate). No other task, except core windows, was running at the
 moment.

 {{{
   GHCi    Stop-watch
  236.03     672.2
   63.52      63.9
   63.01      64.0
 1098.75     671.0
 -365.07      65.2      // it's not a typo, really minus three hundred and
 sixty five
   63.59      63.6
 }}}

 Best regards,

     Dusan

 ---------
 {{{
 module Primes (
           primes1
          ,primes2
          ,primes3
          ,primes2'
          ,primes3'
        ) where


 candidates = map (\x -> (True,x)) [2..]
 candidates' =  [2..]

 skipmap f toSkip list = domap toSkip list
   where
     domap n (x:xs)
       | n > 1  =  x : domap (n-1) xs
       | True   =  f x : domap toSkip xs
     domap _ [] = []

 primes1 = sieve candidates
   where
     sieve (pp@(isp,p):xs)
       | isp  =  p : (sieve $ skipmap (\(_,v) -> (False,v)) p xs)
       | True =  sieve xs

 primes1' = sieve candidates'
   where
     sieve (p:xs)
       | p > 0  =  p : (sieve $ skipmap (\n -> if n>0 then (-n) else n) p
 xs)
       | True   =  sieve xs



 sieve (p:xs) = p : sieve [y | y <- xs, y `mod` p /= 0]
 sieve' (p:xs) = p : sieve [y | y <- xs, y `mod` p > 0]

 primes2  = sieve [2..]
 primes3 = 2 : sieve [3,5..]

 primes2'  = sieve' [2..]
 primes3' = 2 : sieve' [3,5..]
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1621#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to