Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Storing the time difference between two Monotonic time results (David McBride) 2. Re: Storing the time difference between two Monotonic time results (Awsaf Rahman) 3. Re: Storing the time difference between two Monotonic time results (David McBride) 4. Re: Storing the time difference between two Monotonic time results (Awsaf Rahman) ---------------------------------------------------------------------- Message: 1 Date: Mon, 9 Jul 2018 08:45:27 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Storing the time difference between two Monotonic time results Message-ID: <can+tr43kbaf50zetduj8ykqbv2qduxdmgkwczozc1zeri9b...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" There is a diffTimeSpec function in that module that seems like it would work. On Mon, Jul 9, 2018 at 8:30 AM, Awsaf Rahman <awsafrahman1...@gmail.com> wrote: > Hello, > > I am trying to time a function I have written in haskell using the clock > package in the following way: > > *start <- getTime Monotonic* > *evaluate(something)* > *end <- getTime Monotonic* > *fprint (timeSpecs % "\n") start end* > > > Now what I want is to store the time difference between *start* and *end. > *Is there a way I can do that? > > Regards > Awsaf > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180709/2b8b26b6/attachment-0001.html> ------------------------------ Message: 2 Date: Mon, 9 Jul 2018 15:08:42 +0200 From: Awsaf Rahman <awsafrahman1...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Storing the time difference between two Monotonic time results Message-ID: <caoh+qtc2ntpibc1f4iwtux2jrbp7ob_8fnqata8vdgmkhjf...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I imported the System.Clock module and tried to use the diffTimeSpec function but it keeps saying "out of scope". On Mon, Jul 9, 2018 at 2:45 PM, David McBride <toa...@gmail.com> wrote: > There is a diffTimeSpec function in that module that seems like it would > work. > > On Mon, Jul 9, 2018 at 8:30 AM, Awsaf Rahman <awsafrahman1...@gmail.com> > wrote: > >> Hello, >> >> I am trying to time a function I have written in haskell using the clock >> package in the following way: >> >> *start <- getTime Monotonic* >> *evaluate(something)* >> *end <- getTime Monotonic* >> *fprint (timeSpecs % "\n") start end* >> >> >> Now what I want is to store the time difference between *start* and *end. >> *Is there a way I can do that? >> >> Regards >> Awsaf >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180709/09a567c3/attachment-0001.html> ------------------------------ Message: 3 Date: Mon, 9 Jul 2018 09:21:05 -0400 From: David McBride <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Storing the time difference between two Monotonic time results Message-ID: <CAN+Tr43mNpB=hTBmsMusxxSq4NhLKbBH8r=fiztrgfh1j2o...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I guess whatever version you are using did not export that function. In any case the definition for that function is incredibly simple, so you could just write your own for now. diffTimeSpec :: TimeSpec -> TimeSpec -> TimeSpecdiffTimeSpec ts1 ts2 = abs (ts1 - ts2) On Mon, Jul 9, 2018 at 9:08 AM, Awsaf Rahman <awsafrahman1...@gmail.com> wrote: > I imported the System.Clock module and tried to use the diffTimeSpec > function but it keeps saying "out of scope". > > On Mon, Jul 9, 2018 at 2:45 PM, David McBride <toa...@gmail.com> wrote: > >> There is a diffTimeSpec function in that module that seems like it would >> work. >> >> On Mon, Jul 9, 2018 at 8:30 AM, Awsaf Rahman <awsafrahman1...@gmail.com> >> wrote: >> >>> Hello, >>> >>> I am trying to time a function I have written in haskell using the clock >>> package in the following way: >>> >>> *start <- getTime Monotonic* >>> *evaluate(something)* >>> *end <- getTime Monotonic* >>> *fprint (timeSpecs % "\n") start end* >>> >>> >>> Now what I want is to store the time difference between *start* and *end. >>> *Is there a way I can do that? >>> >>> Regards >>> Awsaf >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180709/ca067997/attachment-0001.html> ------------------------------ Message: 4 Date: Mon, 9 Jul 2018 15:40:44 +0200 From: Awsaf Rahman <awsafrahman1...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Storing the time difference between two Monotonic time results Message-ID: <CAOH+QtdC3+N+Hs2h2o8xSG6Lxqs5ZO5YsVUG5KYdek9UGF8t=q...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Okay, here is what I am trying to do. I am trying to time this mergesort program. I want to run this program 100, 1000, etc times and store the timing results in a list if possible. Can't seem to figure out how to do it! The following program prints the timings to the shell and I need to figure out a way to store the timings in a list. {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BangPatterns #-} import Control.Exception import Formatting import Formatting.Clock import System.Clock import Control.DeepSeq mergesort [] = [] mergesort [x] = [x] mergesort xs = let (lhalf, rhalf) = splitAt (length xs `div` 2) xs in merge' (mergesort lhalf) (mergesort rhalf) merge' lhalf rhalf = merge lhalf rhalf [] merge [] [] acc = reverse acc merge [] y acc = reverse acc ++ y merge x [] acc = reverse acc ++ x merge (l:ls) (r:rs) acc | l < r = merge ls (r:rs) (l:acc) | otherwise = merge rs (l:ls) (r:acc) toList :: String -> [Integer] toList input = read ("[" ++ input ++ "]") repeater unsortedlist 0 result = return (result) repeater unsortedlist counter result = do start <- getTime Monotonic evaluate(mergesort unsortedlist) end <- getTime Monotonic fprint (timeSpecs % "\n") start end repeater unsortedlist (counter-1) result main = do file <- getLine contents <- readFile file let !unsortedlist = (toList contents) repeater unsortedlist 100 [] On Mon, Jul 9, 2018 at 3:21 PM, David McBride <toa...@gmail.com> wrote: > I guess whatever version you are using did not export that function. In > any case the definition for that function is incredibly simple, so you > could just write your own for now. > > diffTimeSpec :: TimeSpec -> TimeSpec -> TimeSpecdiffTimeSpec ts1 ts2 = abs > (ts1 - ts2) > > > > On Mon, Jul 9, 2018 at 9:08 AM, Awsaf Rahman <awsafrahman1...@gmail.com> > wrote: > >> I imported the System.Clock module and tried to use the diffTimeSpec >> function but it keeps saying "out of scope". >> >> On Mon, Jul 9, 2018 at 2:45 PM, David McBride <toa...@gmail.com> wrote: >> >>> There is a diffTimeSpec function in that module that seems like it >>> would work. >>> >>> On Mon, Jul 9, 2018 at 8:30 AM, Awsaf Rahman <awsafrahman1...@gmail.com> >>> wrote: >>> >>>> Hello, >>>> >>>> I am trying to time a function I have written in haskell using the >>>> clock package in the following way: >>>> >>>> *start <- getTime Monotonic* >>>> *evaluate(something)* >>>> *end <- getTime Monotonic* >>>> *fprint (timeSpecs % "\n") start end* >>>> >>>> >>>> Now what I want is to store the time difference between *start* and *end. >>>> *Is there a way I can do that? >>>> >>>> Regards >>>> Awsaf >>>> >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners@haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>>> >>>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >>> >>> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180709/2a4f32d8/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 121, Issue 7 *****************************************