Skip to content

Commit

Permalink
Make the benchmarks subtree saner
Browse files Browse the repository at this point in the history
--HG--
rename : tests/benchmarks/.gitignore => benchmarks/.gitignore
rename : tests/benchmarks/Setup.hs => benchmarks/Setup.hs
rename : tests/benchmarks/cbits/time_iconv.c => benchmarks/cbits/time_iconv.c
rename : tests/benchmarks/src/Data/Text/Benchmarks.hs => benchmarks/haskell/Benchmarks.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Builder.hs => benchmarks/haskell/Benchmarks/Builder.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/DecodeUtf8.hs => benchmarks/haskell/Benchmarks/DecodeUtf8.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/EncodeUtf8.hs => benchmarks/haskell/Benchmarks/EncodeUtf8.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Equality.hs => benchmarks/haskell/Benchmarks/Equality.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/FileRead.hs => benchmarks/haskell/Benchmarks/FileRead.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/FoldLines.hs => benchmarks/haskell/Benchmarks/FoldLines.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/BigTable.hs => benchmarks/haskell/Benchmarks/Programs/BigTable.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/Cut.hs => benchmarks/haskell/Benchmarks/Programs/Cut.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/Fold.hs => benchmarks/haskell/Benchmarks/Programs/Fold.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/Sort.hs => benchmarks/haskell/Benchmarks/Programs/Sort.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/StripTags.hs => benchmarks/haskell/Benchmarks/Programs/StripTags.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Programs/Throughput.hs => benchmarks/haskell/Benchmarks/Programs/Throughput.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Pure.hs => benchmarks/haskell/Benchmarks/Pure.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/ReadNumbers.hs => benchmarks/haskell/Benchmarks/ReadNumbers.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Replace.hs => benchmarks/haskell/Benchmarks/Replace.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Search.hs => benchmarks/haskell/Benchmarks/Search.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/Stream.hs => benchmarks/haskell/Benchmarks/Stream.hs
rename : tests/benchmarks/src/Data/Text/Benchmarks/WordFrequencies.hs => benchmarks/haskell/Benchmarks/WordFrequencies.hs
rename : tests/benchmarks/python/.gitignore => benchmarks/python/.gitignore
rename : tests/benchmarks/python/cut.py => benchmarks/python/cut.py
rename : tests/benchmarks/python/sort.py => benchmarks/python/sort.py
rename : tests/benchmarks/python/strip_tags.py => benchmarks/python/strip_tags.py
rename : tests/benchmarks/python/utils.py => benchmarks/python/utils.py
rename : tests/benchmarks/ruby/cut.rb => benchmarks/ruby/cut.rb
rename : tests/benchmarks/ruby/fold.rb => benchmarks/ruby/fold.rb
rename : tests/benchmarks/ruby/sort.rb => benchmarks/ruby/sort.rb
rename : tests/benchmarks/ruby/strip_tags.rb => benchmarks/ruby/strip_tags.rb
rename : tests/benchmarks/ruby/utils.rb => benchmarks/ruby/utils.rb
rename : tests/benchmarks/text-benchmarks.cabal => benchmarks/text-benchmarks.cabal
  • Loading branch information
bos committed Jun 29, 2012
1 parent 6e29fac commit 0922578
Show file tree
Hide file tree
Showing 36 changed files with 86 additions and 83 deletions.
8 changes: 5 additions & 3 deletions Data/Text/Lazy/Fusion.hs
Expand Up @@ -47,6 +47,8 @@ stream text = Stream next (text :*: 0) unknownSize
where Iter c d = iter t i
{-# INLINE [0] stream #-}

data UC s = UC s {-# UNPACK #-} !Int

-- | /O(n)/ Convert a 'Stream Char' into a 'Text', using the given
-- chunk size.
unstreamChunks :: Int -> Stream Char -> Text
Expand All @@ -59,12 +61,12 @@ unstreamChunks chunkSize (Stream next s0 len0)
Done -> Empty
Skip s' -> outer s'
Yield x s' -> I.Text arr 0 len `chunk` outer s''
where (arr,(s'',len)) = A.run2 fill
where (arr, UC s'' len) = A.run2 fill
fill = do a <- A.new unknownLength
unsafeWrite a 0 x >>= inner a unknownLength s'
unknownLength = 4
inner marr len s !i
| i + 1 >= chunkSize = return (marr, (s,i))
| i + 1 >= chunkSize = return (marr, UC s i)
| i + 1 >= len = {-# SCC "unstreamChunks/resize" #-} do
let newLen = min (len `shiftL` 1) chunkSize
marr' <- A.new newLen
Expand All @@ -73,7 +75,7 @@ unstreamChunks chunkSize (Stream next s0 len0)
| otherwise =
{-# SCC "unstreamChunks/inner" #-}
case next s of
Done -> return (marr,(s,i))
Done -> return (marr, UC s i)
Skip s' -> inner marr len s' i
Yield x s' -> do d <- unsafeWrite marr i x
inner marr len s' (i+d)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -9,25 +9,25 @@ import Criterion.Main (Benchmark, defaultMain, bgroup)
import System.FilePath ((</>))
import System.IO (IOMode (WriteMode), openFile, hSetEncoding, utf8)

import qualified Data.Text.Benchmarks.Builder as Builder
import qualified Data.Text.Benchmarks.DecodeUtf8 as DecodeUtf8
import qualified Data.Text.Benchmarks.EncodeUtf8 as EncodeUtf8
import qualified Data.Text.Benchmarks.Equality as Equality
import qualified Data.Text.Benchmarks.FileRead as FileRead
import qualified Data.Text.Benchmarks.FoldLines as FoldLines
import qualified Data.Text.Benchmarks.Pure as Pure
import qualified Data.Text.Benchmarks.ReadNumbers as ReadNumbers
import qualified Data.Text.Benchmarks.Replace as Replace
import qualified Data.Text.Benchmarks.Search as Search
import qualified Data.Text.Benchmarks.Stream as Stream
import qualified Data.Text.Benchmarks.WordFrequencies as WordFrequencies
import qualified Benchmarks.Builder as Builder
import qualified Benchmarks.DecodeUtf8 as DecodeUtf8
import qualified Benchmarks.EncodeUtf8 as EncodeUtf8
import qualified Benchmarks.Equality as Equality
import qualified Benchmarks.FileRead as FileRead
import qualified Benchmarks.FoldLines as FoldLines
import qualified Benchmarks.Pure as Pure
import qualified Benchmarks.ReadNumbers as ReadNumbers
import qualified Benchmarks.Replace as Replace
import qualified Benchmarks.Search as Search
import qualified Benchmarks.Stream as Stream
import qualified Benchmarks.WordFrequencies as WordFrequencies

import qualified Data.Text.Benchmarks.Programs.BigTable as Programs.BigTable
import qualified Data.Text.Benchmarks.Programs.Cut as Programs.Cut
import qualified Data.Text.Benchmarks.Programs.Fold as Programs.Fold
import qualified Data.Text.Benchmarks.Programs.Sort as Programs.Sort
import qualified Data.Text.Benchmarks.Programs.StripTags as Programs.StripTags
import qualified Data.Text.Benchmarks.Programs.Throughput as Programs.Throughput
import qualified Benchmarks.Programs.BigTable as Programs.BigTable
import qualified Benchmarks.Programs.Cut as Programs.Cut
import qualified Benchmarks.Programs.Fold as Programs.Fold
import qualified Benchmarks.Programs.Sort as Programs.Sort
import qualified Benchmarks.Programs.StripTags as Programs.StripTags
import qualified Benchmarks.Programs.Throughput as Programs.Throughput

main :: IO ()
main = benchmarks >>= defaultMain
Expand Down
Expand Up @@ -5,7 +5,7 @@
-- * Concatenating many small strings using a builder
--
{-# LANGUAGE OverloadedStrings #-}
module Data.Text.Benchmarks.Builder
module Benchmarks.Builder
( benchmark
) where

Expand Down
Expand Up @@ -14,7 +14,7 @@
--
-- The latter are used for testing stream fusion.
--
module Data.Text.Benchmarks.DecodeUtf8
module Benchmarks.DecodeUtf8
( benchmark
) where

Expand Down
Expand Up @@ -6,7 +6,7 @@
--
-- * UTF-8 encoding it
--
module Data.Text.Benchmarks.EncodeUtf8
module Benchmarks.EncodeUtf8
( benchmark
) where

Expand Down
Expand Up @@ -5,7 +5,7 @@
--
-- * Comparison of strings (Eq instance)
--
module Data.Text.Benchmarks.Equality
module Benchmarks.Equality
( benchmark
) where

Expand Down
Expand Up @@ -4,7 +4,7 @@
--
-- * Reading a file from the disk
--
module Data.Text.Benchmarks.FileRead
module Benchmarks.FileRead
( benchmark
) where

Expand Down
Expand Up @@ -6,7 +6,7 @@
-- * Buffered, line-based IO
--
{-# LANGUAGE BangPatterns #-}
module Data.Text.Benchmarks.FoldLines
module Benchmarks.FoldLines
( benchmark
) where

Expand Down
Expand Up @@ -7,7 +7,7 @@
-- * Writing to a handle
--
{-# LANGUAGE OverloadedStrings #-}
module Data.Text.Benchmarks.Programs.BigTable
module Benchmarks.Programs.BigTable
( benchmark
) where

Expand Down
Expand Up @@ -12,7 +12,7 @@
--
-- * Writing back to a handle
--
module Data.Text.Benchmarks.Programs.Cut
module Benchmarks.Programs.Cut
( benchmark
) where

Expand Down
Expand Up @@ -13,7 +13,7 @@
-- * Writing back to a handle
--
{-# LANGUAGE OverloadedStrings #-}
module Data.Text.Benchmarks.Programs.Fold
module Benchmarks.Programs.Fold
( benchmark
) where

Expand Down
Expand Up @@ -13,7 +13,7 @@
-- * Writing back to a handle
--
{-# LANGUAGE OverloadedStrings #-}
module Data.Text.Benchmarks.Programs.Sort
module Benchmarks.Programs.Sort
( benchmark
) where

Expand Down
Expand Up @@ -11,7 +11,7 @@
-- * Writing back to a handle
--
{-# OPTIONS_GHC -fspec-constr-count=5 #-}
module Data.Text.Benchmarks.Programs.StripTags
module Benchmarks.Programs.StripTags
( benchmark
) where

Expand Down
Expand Up @@ -14,7 +14,7 @@
--
-- * Writing back to a handle
--
module Data.Text.Benchmarks.Programs.Throughput
module Benchmarks.Programs.Throughput
( benchmark
) where

Expand Down
Expand Up @@ -6,7 +6,7 @@
--
{-# LANGUAGE BangPatterns, GADTs, MagicHash #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.Text.Benchmarks.Pure
module Benchmarks.Pure
( benchmark
) where

Expand Down
Expand Up @@ -16,7 +16,7 @@
--
-- * Lexing/parsing of different numerical types
--
module Data.Text.Benchmarks.ReadNumbers
module Benchmarks.ReadNumbers
( benchmark
) where

Expand Down
Expand Up @@ -4,7 +4,7 @@
--
-- * Search and replace of a pattern in a text
--
module Data.Text.Benchmarks.Replace
module Benchmarks.Replace
( benchmark
) where

Expand Down
Expand Up @@ -4,7 +4,7 @@
--
-- * Searching all occurences of a pattern using library routines
--
module Data.Text.Benchmarks.Search
module Benchmarks.Search
( benchmark
) where

Expand Down
Expand Up @@ -7,7 +7,7 @@
--
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.Text.Benchmarks.Stream
module Benchmarks.Stream
( benchmark
) where

Expand Down
Expand Up @@ -8,7 +8,7 @@
--
-- * Comparing: Eq/Ord instances
--
module Data.Text.Benchmarks.WordFrequencies
module Benchmarks.WordFrequencies
( benchmark
) where

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions benchmarks/text-benchmarks.cabal
@@ -0,0 +1,37 @@
name: text-benchmarks
version: 0.0.0.0
synopsis: Benchmarks for the text package
description: Benchmarks for the text package
homepage: https://bitbucket.org/bos/text
license: BSD3
license-file: ../LICENSE
author: Jasper Van der Jeugt <jaspervdj@gmail.com>,
Bryan O'Sullivan <bos@serpentine.com>,
Tom Harper <rtomharper@googlemail.com>,
Duncan Coutts <duncan@haskell.org>
maintainer: jaspervdj@gmail.com
category: Text
build-type: Simple

cabal-version: >=1.2

executable text-benchmarks
hs-source-dirs: haskell ..
c-sources: ../cbits/cbits.c
cbits/time_iconv.c
main-is: Benchmarks.hs
ghc-options: -Wall -O2
cpp-options: -DHAVE_DEEPSEQ
build-depends: base == 4.*,
binary,
blaze-builder,
bytestring,
bytestring-lexing,
containers,
criterion >= 0.6.0.1,
deepseq,
directory,
filepath,
ghc-prim,
stringsearch,
utf8-string
36 changes: 0 additions & 36 deletions tests/benchmarks/text-benchmarks.cabal

This file was deleted.

16 changes: 8 additions & 8 deletions text.cabal
Expand Up @@ -49,18 +49,18 @@ category: Data, Text
build-type: Simple
cabal-version: >= 1.8
extra-source-files:
README.markdown
-- scripts/CaseFolding.txt
-- scripts/SpecialCasing.txt
README.markdown
benchmarks/Setup.hs
benchmarks/cbits/*.c
benchmarks/python/*.py
benchmarks/ruby/*.rb
benchmarks/src/Data/Text/*.hs
benchmarks/src/Data/Text/Benchmarks/*.hs
benchmarks/text-benchmarks.cabal
scripts/*.hs
tests/README.markdown
tests/benchmarks/Setup.hs
tests/benchmarks/cbits/*.c
tests/benchmarks/python/*.py
tests/benchmarks/ruby/*.rb
tests/benchmarks/src/Data/Text/*.hs
tests/benchmarks/src/Data/Text/Benchmarks/*.hs
tests/benchmarks/text-benchmarks.cabal
tests/tests/.ghci
tests/tests/Makefile
tests/tests/scripts/*.sh
Expand Down

0 comments on commit 0922578

Please sign in to comment.