on master help sign in
added tests dir and first benchmarking code
commita5fdff1dba06bcfc043e49ccde3c173a6450acb0 authorMark Lentczner <markl@glyphic.com> dateSat 26 Dec 2009, 07:03 (17 years ago) parent2ca3a37
3 files changed+71
tests/BenchUUID.hs+37 tests/Setup.hs+4 tests/uuid-tests.cabal+30
tests/BenchUUID.hsnew file+37
@@ -0,0 +1,37 @@
1+import Control.Monad (replicateM)
2+import Control.Parallel.Strategies
3+import Criterion.Main
4+import Data.Maybe (fromJust)
5+import qualified Data.ByteString.Lazy as BL
6+import qualified Data.ByteString.Lazy.Internal as BL
7+import qualified Data.UUID as U
8+import qualified Data.UUID.Internal as U
9+import System.Random
10+
11+
12+instance NFData BL.ByteString where
13+ rnf BL.Empty = ()
14+ rnf (BL.Chunk _ ts) = rnf ts
15+
16+instance NFData U.UUID where
17+ rnf (U.UUID tl tm th ch cl node) =
18+ rnf tl `seq` rnf tm `seq` rnf th `seq` rnf ch `seq` rnf cl `seq` rnf node
19+
20+instance NFData U.Node where
21+ rnf (U.Node w1 w2 w3 w4 w5 w6) =
22+ rnf w1 `seq` rnf w2 `seq` rnf w3 `seq` rnf w4 `seq` rnf w5 `seq` rnf w6
23+
24+
25+
26+main :: IO ()
27+main = do
28+ u1 <- randomIO
29+ let s1 = U.toString u1
30+ b1 = U.toByteString u1
31+ defaultMain [
32+ bench "toString" $ B (rnf . U.toString) u1,
33+ bench "fromString" $ B (rnf . U.fromString) s1,
34+ bench "toByteString" $ B (rnf . U.toByteString) u1,
35+ bench "fromByteString" $ B (rnf . U.fromByteString) b1,
36+ bench "random gen" $ (randomIO :: IO U.UUID)
37+ ]
tests/Setup.hsnew file+4
@@ -0,0 +1,4 @@
1+import Distribution.Simple
2+main :: IO ()
3+main = defaultMain
4+
tests/uuid-tests.cabalnew file+30
@@ -0,0 +1,30 @@
1+Name: uuid-tests
2+Version: 1.0.0
3+Copyright: (c) 2009 Antoine Latter
4+Author: Antoine Latter
5+Maintainer: aslatter@gmail.com
6+License: BSD3
7+License-file: ../LICENSE
8+
9+Category: Data
10+Build-Type: Simple
11+Cabal-Version: >= 1.6
12+
13+Description:
14+ This is a set of test programs for testing the uuid package.
15+
16+Synopsis: This is a set of test programs for testing the uuid package.
17+
18+Homepage: http://community.haskell.org/~aslatter/code/uuid/
19+Bug-Reports: mailto:aslatter@gmail.com
20+
21+
22+Executable benchuuid
23+ Main-Is: BenchUUID.hs
24+ HS-Source-Dirs: . ..
25+ Build-Depends: random, binary, bytestring, Crypto, maccatcher,
26+ time, base >=3, base < 5,
27+ criterion >= 0.3 && < 0.4, parallel >= 2.1 && < 2.3
28+
29+ Extensions: DeriveDataTypeable
30+