Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Difference of time execution times when measuring with time
and profiling (Javier de Vega Ruiz)
2. Re: Difference of time execution times when measuring with
time and profiling (Thomas Koster)
3. Processing data from microphone interactively (Martin Vlk)
----------------------------------------------------------------------
Message: 1
Date: Thu, 22 Oct 2015 17:00:11 +0100
From: Javier de Vega Ruiz <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Difference of time execution times when
measuring with time and profiling
Message-ID:
<cab9urnrko+bf-m6qny1_ovwinyt-_2otaq-3emfjvq9kt8r...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
HI all,
I am messing around with bang patterns and noticed some huge differences
between the total time as reported by the time tool and the .prof file.
Below is the code used.
Without bang patterns:
module Main where
import Data.List
fastFibs =
unfoldr nextFib (1, 1)
where nextFib (x, y) = Just $ (x, (y, (x + y)))
main =
putStrLn $ (show n) ++ "th fib is: " ++ (show $ fastFibs !! (n - 1))
where n = 1000000
With bang patterns:
{-# LANGUAGE BangPatterns #-}
module Main where
import Data.List
fastFibs =
unfoldr nextFib (1, 1)
where nextFib (!x, !y) = Just $ (x, (y, (x + y)))
main =
putStrLn $ (show n) ++ "th fib is: " ++ (show $ fastFibs !! (n - 1))
where n = 1000000
when looking at the first through time and prof I get the following.
Without:
real 0m53.501s
user 0m0.015s
sys 0m0.328s
Thu Oct 22 16:46 2015 Time and Allocation Profiling Report (Final)
fast-fib.exe +RTS -p -RTS
total time = 9.52 secs (9520 ticks @ 1000 us, 1 processor)
total alloc = 43,500,223,152 bytes (excludes profiling overheads)
Please note the huge difference 53 vs 9 seconds.
With:
real 0m10.095s
user 0m0.031s
sys 0m0.344s
Thu Oct 22 16:50 2015 Time and Allocation Profiling Report (Final)
fast-fib.exe +RTS -p -RTS
total time = 8.97 secs (8971 ticks @ 1000 us, 1 processor)
total alloc = 43,500,309,960 bytes (excludes profiling overheads)
Here differences seem to be much smaller.
I am using Windows 8.1 64 bit, GHC 7.8.3 and measuring with the following
line:
ghc Main.hs -o fast-fib.exe -O2 -prof && time ./fast-fib.exe +RTS -p && cat
fast-fib.prof
Could someone please explain where the big difference is coming from and
how to change the measuring approach to get more consistent results?
Best regards,
Javier de Vega Ruiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151022/39c7119d/attachment-0001.html>
------------------------------
Message: 2
Date: Fri, 23 Oct 2015 11:27:47 +1100
From: Thomas Koster <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Difference of time execution times
when measuring with time and profiling
Message-ID:
<CAG1wH7BGSUqoXquzToLb9t5LmN=6b_qj65r1frkmgxefw-6...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Javier,
On 23 October 2015 at 03:00, Javier de Vega Ruiz
<[email protected]> wrote:
> I am messing around with bang patterns and noticed some huge differences
> between the total time as reported by the time tool and the .prof file.
> Below is the code used.
> Without bang patterns:
> module Main where
>
> import Data.List
>
> fastFibs =
> unfoldr nextFib (1, 1)
> where nextFib (x, y) = Just $ (x, (y, (x + y)))
>
> main =
> putStrLn $ (show n) ++ "th fib is: " ++ (show $ fastFibs !! (n - 1))
> where n = 1000000
>
> With bang patterns:
> {-# LANGUAGE BangPatterns #-}
>
> module Main where
>
> import Data.List
>
> fastFibs =
> unfoldr nextFib (1, 1)
> where nextFib (!x, !y) = Just $ (x, (y, (x + y)))
>
> main =
> putStrLn $ (show n) ++ "th fib is: " ++ (show $ fastFibs !! (n - 1))
> where n = 1000000
>
> when looking at the first through time and prof I get the following.
> Without:
> real 0m53.501s
> user 0m0.015s
> sys 0m0.328s
> Thu Oct 22 16:46 2015 Time and Allocation Profiling Report (Final)
>
> fast-fib.exe +RTS -p -RTS
>
> total time = 9.52 secs (9520 ticks @ 1000 us, 1 processor)
> total alloc = 43,500,223,152 bytes (excludes profiling overheads)
>
> Please note the huge difference 53 vs 9 seconds.
>
> With:
> real 0m10.095s
> user 0m0.031s
> sys 0m0.344s
> Thu Oct 22 16:50 2015 Time and Allocation Profiling Report (Final)
>
> fast-fib.exe +RTS -p -RTS
>
> total time = 8.97 secs (8971 ticks @ 1000 us, 1 processor)
> total alloc = 43,500,309,960 bytes (excludes profiling overheads)
>
> Here differences seem to be much smaller.
>
> I am using Windows 8.1 64 bit, GHC 7.8.3 and measuring with the following
> line:
> ghc Main.hs -o fast-fib.exe -O2 -prof && time ./fast-fib.exe +RTS -p && cat
> fast-fib.prof
>
> Could someone please explain where the big difference is coming from and how
> to change the measuring approach to get more consistent results?
Before going into why the numbers are what they are, I think there is
something wrong with your time tool on Windows. Your "user" time is
suspiciously low in both measurements. When I ran your program on
Linux, the report from the -s RTS option and the "real" and "user"
numbers from the time tool were within milliseconds of each other
(qualification: I used GHC 7.10.2).
Apart from that, I am pretty sure the -p RTS option and the time tool
are not measuring the same thing. I think the profiler samples "ticks"
in the runtime, whereas the time tool and the -s option probably use
CPU performance counters. Somebody more familiar with the GHC runtime
should be able to give you more detail.
--
Thomas Koster
------------------------------
Message: 3
Date: Fri, 23 Oct 2015 10:01:23 +0000
From: Martin Vlk <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Processing data from microphone
interactively
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Hi,
I am looking at reading sound from a microphone and controlling some
other activity based on the sound data as they come. The motivation for
this is writing some interactive animated graphics controlled by
properties of the sound from mic.
I am using the pulseaudio-simple library to read sound from the computer
mic and that works fine. However the library function basically returns
sound samples as a list of predefined length and this is not well suited
for the kind of real-time processing I need.
I am looking for advice on what would be a good idiomatic way to design
such a program in Haskell.
>From some research I am imagining I need something like the conduit
library to connect the sound data to other parts of my program, but I am
not sure how that would work or if it is a good idea in the first place.
Or should I use some of the FRP libraries for this purpose?
Or some other approach?
I'd appreciate some advice on the direction to take.
Many Thanks
Martin
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 88, Issue 19
*****************************************