Created
August 13, 2016 23:09
-
-
Save michaelt/b7e74602a52c0b36eb244c221e6177a8 to your computer and use it in GitHub Desktop.
bench Foundation compared to Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benchmarking map/map/foundation | |
time 49.63 μs (49.10 μs .. 50.25 μs) | |
0.999 R² (0.999 R² .. 0.999 R²) | |
mean 50.16 μs (49.64 μs .. 50.70 μs) | |
std dev 1.754 μs (1.517 μs .. 2.147 μs) | |
variance introduced by outliers: 37% (moderately inflated) | |
benchmarking map/map/text | |
time 5.990 μs (5.874 μs .. 6.122 μs) | |
0.998 R² (0.997 R² .. 0.999 R²) | |
mean 6.003 μs (5.931 μs .. 6.073 μs) | |
std dev 239.5 ns (201.5 ns .. 291.1 ns) | |
variance introduced by outliers: 50% (severely inflated) | |
benchmarking map/map-map/foundation | |
time 98.84 μs (97.84 μs .. 100.2 μs) | |
0.999 R² (0.998 R² .. 0.999 R²) | |
mean 99.45 μs (98.56 μs .. 100.5 μs) | |
std dev 3.333 μs (2.746 μs .. 4.217 μs) | |
variance introduced by outliers: 33% (moderately inflated) | |
benchmarking map/map-map/text | |
time 5.270 μs (5.202 μs .. 5.335 μs) | |
0.999 R² (0.998 R² .. 0.999 R²) | |
mean 5.260 μs (5.197 μs .. 5.320 μs) | |
std dev 198.2 ns (164.7 ns .. 247.0 ns) | |
variance introduced by outliers: 48% (moderately inflated) | |
benchmarking drop/drop/foundation | |
time 258.4 ns (255.0 ns .. 261.3 ns) | |
0.999 R² (0.999 R² .. 0.999 R²) | |
mean 257.5 ns (254.3 ns .. 260.2 ns) | |
std dev 10.10 ns (8.092 ns .. 13.45 ns) | |
variance introduced by outliers: 58% (severely inflated) | |
benchmarking drop/drop/text | |
time 41.91 ns (41.51 ns .. 42.30 ns) | |
0.999 R² (0.999 R² .. 1.000 R²) | |
mean 42.25 ns (41.82 ns .. 42.72 ns) | |
std dev 1.559 ns (1.235 ns .. 2.099 ns) | |
variance introduced by outliers: 58% (severely inflated) | |
benchmarking drop/map.drop/foundation | |
time 46.39 μs (45.82 μs .. 46.93 μs) | |
0.999 R² (0.998 R² .. 0.999 R²) | |
mean 46.39 μs (45.85 μs .. 47.19 μs) | |
std dev 2.198 μs (1.552 μs .. 3.356 μs) | |
variance introduced by outliers: 53% (severely inflated) | |
benchmarking drop/map.drop/text | |
time 3.106 μs (3.064 μs .. 3.148 μs) | |
0.999 R² (0.998 R² .. 0.999 R²) | |
mean 3.090 μs (3.059 μs .. 3.122 μs) | |
std dev 102.1 ns (81.65 ns .. 131.0 ns) | |
variance introduced by outliers: 43% (moderately inflated) | |
benchmarking break/#english-start/foundation | |
time 17.40 ns (17.26 ns .. 17.56 ns) | |
0.999 R² (0.999 R² .. 1.000 R²) | |
mean 17.39 ns (17.21 ns .. 17.56 ns) | |
std dev 628.4 ps (540.1 ps .. 731.0 ps) | |
variance introduced by outliers: 59% (severely inflated) | |
benchmarking break/#english-start/text | |
time 12.63 ns (12.35 ns .. 13.10 ns) | |
0.997 R² (0.993 R² .. 0.999 R²) | |
mean 12.72 ns (12.58 ns .. 12.90 ns) | |
std dev 516.4 ps (396.4 ps .. 783.7 ps) | |
variance introduced by outliers: 65% (severely inflated) | |
benchmarking break/#english-middle/foundation | |
time 98.93 ns (97.51 ns .. 100.3 ns) | |
0.999 R² (0.999 R² .. 1.000 R²) | |
mean 99.28 ns (98.32 ns .. 100.5 ns) | |
std dev 3.643 ns (2.720 ns .. 4.598 ns) | |
variance introduced by outliers: 56% (severely inflated) | |
benchmarking break/#english-middle/text | |
time 108.8 ns (107.1 ns .. 110.8 ns) | |
0.998 R² (0.997 R² .. 0.999 R²) | |
mean 109.3 ns (108.0 ns .. 110.6 ns) | |
std dev 4.443 ns (3.788 ns .. 5.230 ns) | |
variance introduced by outliers: 61% (severely inflated) | |
benchmarking break/#english-notfound/foundation | |
time 374.6 ns (370.0 ns .. 379.4 ns) | |
0.999 R² (0.998 R² .. 0.999 R²) | |
mean 377.9 ns (373.9 ns .. 382.1 ns) | |
std dev 13.12 ns (11.28 ns .. 15.54 ns) | |
variance introduced by outliers: 51% (severely inflated) | |
benchmarking break/#english-notfound/text | |
time 426.1 ns (416.9 ns .. 435.4 ns) | |
0.998 R² (0.995 R² .. 0.999 R²) | |
mean 420.1 ns (415.9 ns .. 426.3 ns) | |
std dev 16.71 ns (12.79 ns .. 24.18 ns) | |
variance introduced by outliers: 57% (severely inflated) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import qualified Foundation as F | |
import qualified Foundation.Collection as F | |
import qualified Foundation.String as F | |
import Criterion.Main | |
import qualified Data.Text as T | |
textEnglish = "Set in the year 0 F.E. (\"Foundation Era\"), The Psychohistorians opens on Trantor, the capital of the 12,000-year-old Galactic Empire. Though the empire appears stable and powerful, it is slowly decaying in ways that parallel the decline of the Western Roman Empire. Hari Seldon, a mathematician and psychologist, has developed psychohistory, a new field of science and psychology that equates all possibilities in large societies to mathematics, allowing for the prediction of future events." | |
textJapanese = "数学者ハリ・セルダンは、膨大な集団の行動を予測する心理歴史学を作りあげ発展させることで、銀河帝国が近いうちに崩壊することを予言する[1]。セルダンは、帝国崩壊後に3万年続くはずの暗黒時代を、あらゆる知識を保存することで千年に縮めようとし、知識の集大成となる銀河百科事典 (Encyclopedia Galactica) を編纂するグループ「ファウンデーション」をつくったが、帝国崩壊を公言し平和を乱したという罪で裁判にかけられ、グループは銀河系辺縁部にある資源の乏しい無人惑星ターミナスへ追放されることになった。しかし、この追放劇すらもセルダンの計画に予定されていた事柄であった。病で死期をさとっていたセルダンは、己の仕事が終わったことを確信する。" | |
main = defaultMain | |
[ bgroup "map" | |
[ bgroup "map" | |
[ bench "foundation" $ whnf (F.imap succ) (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (T.map succ) (T.pack textEnglish) | |
] | |
, bgroup "map.map" | |
[ bench "foundation" $ whnf (F.imap pred . F.imap succ) (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (T.map pred . T.map succ) (T.pack textEnglish) | |
] | |
] | |
, bgroup "drop" | |
[ bgroup "drop" | |
[ bench "foundation" $ whnf (F.drop 30) (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (T.drop 30) (T.pack textEnglish) | |
] | |
, bgroup "map.drop" | |
[ bench "foundation" $ whnf (F.imap succ . F.drop 30) (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (T.map succ . T.drop 30) (T.pack textEnglish) | |
] | |
] | |
, bgroup "break" | |
[ bgroup "#english-start" | |
[ bench "foundation" $ whnf (fst . F.breakElem 'S') (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (fst . T.break (== 'S')) (T.pack textEnglish) | |
] | |
, bgroup "#english-middle" | |
[ bench "foundation" $ whnf (fst . F.breakElem '2') (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (fst . T.break (== '2')) (T.pack textEnglish) | |
] | |
, bgroup "#english-notfound" | |
[ bench "foundation" $ whnf (fst . F.breakElem 'z') (F.fromList textEnglish :: F.String) | |
, bench "text" $ whnf (fst . T.break (== 'z')) (T.pack textEnglish) | |
] | |
{- | |
, bgroup "#japanese" | |
[ bench "foundation" $ whnf (fst . F.breakElem '帝') (F.fromList textJapanese :: F.String) | |
, bench "text" $ whnf (fst . T.break (== '帝')) (T.pack textJapanese) | |
] | |
-} | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment