[Haskell-cafe] Precise timing

Carter Schonwald carter.schonwald at gmail.com
Sun Oct 19 04:48:38 UTC 2014


if you care about precise timing (at the cost of of some loss of throughput)
you can compile your code with -fno-omit-yields, and also the context
switching timer
see eg
http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/using-concurrent.html

default context switching rate for threads is -C0.02 (20ms), but you can
set the rate as small as you like, and -C0 will trigger a context switch at
every yield.

happy experimenting!

On Sat, Oct 18, 2014 at 10:19 PM, Brandon Allbery <allbery.b at gmail.com>
wrote:

> On Sat, Oct 18, 2014 at 9:36 PM, Jeffrey Brown <jeffbrown.the at gmail.com>
> wrote:
>
>> threadDelay is guaranteed
>> <http://hackage.haskell.org/package/base-4.7.0.1/docs/Control-Concurrent.html#v:threadDelay>
>>
>>  to wait at least as long, but potentially longer than, what the caller
>> specifies. Another potential problem could be buffering in printf.
>> (Eventually I intend to replace the printf statement with OSC output to a
>> sound generator.)
>>
>
> This isn't going to be solved completely within Haskell; the behavior of
> threadDelay is the behavior of the system scheduler for a normal process,
> possibly modified by garbage collection delays. You'll need to switch the
> process to a realtime scheduling class to remove --- or at least reduce ---
> the OS's contribution to the uncertainties in sleep times.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141019/9dd254ad/attachment.html>


More information about the Haskell-Cafe mailing list