Browse files

Case mapping benchmark

  • Loading branch information...
1 parent a4b836b commit 8fa25cbb080d948710ecafa21fa375e6155e47e8 @bos committed Nov 8, 2010
Showing with 36 additions and 0 deletions.
  1. +21 −0 tests/benchmarks/CaseMap.hs
  2. +15 −0 tests/benchmarks/casemap.py
View
21 tests/benchmarks/CaseMap.hs
@@ -0,0 +1,21 @@
+import Control.Exception
+import Control.Monad
+import Data.Time.Clock
+import Data.ByteString as B
+import Data.Text.Encoding as T
+import Data.Text as T
+import System.Environment
+
+time act = do
+ start <- getCurrentTime
+ act
+ end <- getCurrentTime
+ let d = diffUTCTime end start
+ print d
+
+main = do
+ args <- getArgs
+ forM_ args $ \f -> do
+ t <- T.decodeUtf8 `fmap` B.readFile f
+ evaluate t
+ time $ evaluate (T.toUpper t)
View
15 tests/benchmarks/casemap.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+import sys, time
+
+def timeit(f):
+ start = time.time()
+ f()
+ end = time.time()
+ print end - start
+
+for f in sys.argv[1:]:
+ s = open(f).read()
+ u = s.decode('utf8')
+ timeit(lambda: s.upper())
+ timeit(lambda: u.upper())

0 comments on commit 8fa25cb

Please sign in to comment.