Replaced throw to throwIO where type is IO

Bas van Dijk v.dijk.bas at gmail.com
Sat Sep 25 11:55:40 EDT 2010


On Sat, Sep 25, 2010 at 5:34 PM, Gregory Collins
<greg at gregorycollins.net> wrote:
> Bas van Dijk <v.dijk.bas at gmail.com> writes:
>
>> throwIOs :: Int -> IO ()
>> throwIOs 0 = return ()
>> throwIOs n = throwIO DivideByZero `catch` \DivideByZero -> throws (n-1)
>
> Should that perhaps be "throwIOs (n-1)" in the recursive case?

Oops! Good catch.

Rerunning it with the correct definition:

$ ./throwing
warming up
estimating clock resolution...
mean is 21.03730 us (40001 iterations)
found 1716 outliers among 39999 samples (4.3%)
  1402 (3.5%) high severe
estimating cost of a clock call...
mean is 1.902708 us (43 iterations)
found 2 outliers among 43 samples (4.7%)
  2 (4.7%) high severe

benchmarking throw
collecting 100 samples, 1 iterations each, in estimated 21.07508 s
bootstrapping with 100000 resamples
mean: 212.2662 ms, lb 211.7532 ms, ub 213.0318 ms, ci 0.950
std dev: 3.153136 ms, lb 2.307677 ms, ub 4.915720 ms, ci 0.950
found 10 outliers among 100 samples (10.0%)
  1 (1.0%) low severe
  5 (5.0%) high mild
  4 (4.0%) high severe
variance introduced by outliers: 0.993%
variance is unaffected by outliers

benchmarking throwIO
collecting 100 samples, 1 iterations each, in estimated 17.07039 s
bootstrapping with 100000 resamples
mean: 174.1298 ms, lb 172.5284 ms, ub 178.3283 ms, ci 0.950
std dev: 12.27940 ms, lb 5.843075 ms, ub 25.16350 ms, ci 0.950
found 9 outliers among 100 samples (9.0%)
  2 (2.0%) high mild
  7 (7.0%) high severe
variance introduced by outliers: 1.000%
variance is unaffected by outliers

Now this is surprising, throwIO is actually faster than throw.

I'll see if the core sheds any light on this.

Bas


More information about the Libraries mailing list