bos/aeson — pull request #41 by basvandijk (2011-11-16 20:26:52+00:00)
Title: Use HashMap instead of Map for Objects

Since the keys in `Objects` are always `Text` values and since `HashMap`s are reportedly faster than `Map`s when key comparison is expensive as in the case of strings, I thought lets see how much faster `aeson` becomes.

The `AesonCompareAutoInstances` benchmarks give some nice speedups:

* 24.7% speedup on average
* 98.0% maximum speedup
* -1.7% maximum slowdown

```
Benchmark Mean (Map) Mean (HashMap) % faster
D/toJSON/th 3.51032386728728e-6 8.654912132302048e-8 97.5344405646
D/toJSON/syb 3.261817639090798e-5 1.8685494658370343e-6 94.2714471728
D/toJSON/generic 3.2741720090006598e-6 6.451152344156847e-8 98.0296843518
D/fromJSON/th 6.607718628404777e-6 6.556488360047271e-6 0.7753094712
D/fromJSON/syb 2.2697236504524376e-5 2.2431176419119282e-5 1.172213566
D/fromJSON/generic 7.471642633198728e-6 7.419472903478574e-6 0.6982364158
BigRecord/toJSON/th 8.947866949380614e-6 3.3366562513473597e-6 62.7100372611
BigRecord/toJSON/syb 4.9387507335559746e-5 4.605180456191914e-5 6.7541428057
BigRecord/toJSON/generic 8.92993244247057e-6 3.3148976255804462e-6 62.8788051093
BigRecord/fromJSON/th 8.710332806139106e-6 5.1881908751279805e-6 40.436364596
BigRecord/fromJSON/syb 3.610714885976055e-5 3.301600625383713e-5 8.5610265655
BigRecord/fromJSON/generic 9.93372668116546e-6 6.3319026758705355e-6 36.258537414
BigProduct/toJSON/th 1.6025637792230965e-6 1.619670379103017e-6 -1.0674520479
BigProduct/toJSON/syb 2.949057134505241e-5 2.9822362355391186e-5 -1.1250748806
BigProduct/toJSON/generic 1.6323156490076052e-6 1.6537865915445512e-6 -1.3153670707
BigProduct/fromJSON/th 2.448322307421248e-6 2.357275918260351e-6 3.7187256304
BigProduct/fromJSON/syb 1.8371472295125336e-5 1.8493064301709337e-5 -0.6618522709
BigProduct/fromJSON/generic 2.200696904335349e-6 2.1631248248561965e-6 1.7072809711
BigSum/toJSON/th 6.375484844235845e-8 2.828451755846632e-8 55.6355034174
BigSum/toJSON/syb 1.2746111603537255e-6 1.2808111294154723e-6 -0.486420428
BigSum/toJSON/generic 6.525936276021016e-8 5.64113955685751e-8 13.5581575078
BigSum/fromJSON/th 4.3108601644599946e-7 3.8569804287686297e-7 10.52875107
BigSum/fromJSON/syb 4.132365482662795e-6 3.991339410837181e-6 3.4127202063
BigSum/fromJSON/generic 1.1023105485098705e-5 1.1210366740837888e-5 -1.698806711
```

(Benchmarked with `ghc-7.2.2` with `-O2`)

BTW I had to remove the derived `Data` instance for `Value` since `HashMap` doesn't have a `Data` instance. I'm not sure this is a problem.