Last active
August 29, 2015 14:17
-
-
Save japesinator/5acfcc9a5556f09ff970 to your computer and use it in GitHub Desktop.
This file contains 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
Programming_Misc/Haskell/integral » cabal build && cabal install && .cabal-sandbox/bin/integralbench | |
Building integralbench-0.1.0.0... | |
Preprocessing executable 'integralbench' for integralbench-0.1.0.0... | |
[1 of 1] Compiling Main ( Main.hs, dist/build/integralbench/integralbench-tmp/Main.o ) | |
Linking dist/build/integralbench/integralbench ... | |
Resolving dependencies... | |
Notice: installing into a sandbox located at | |
/Users/jp/Programming_Misc/Haskell/integral/.cabal-sandbox | |
Configuring integralbench-0.1.0.0... | |
Building integralbench-0.1.0.0... | |
Installed integralbench-0.1.0.0 | |
benchmarking integral/mine 1 | |
time 17.36 ns (17.11 ns .. 17.63 ns) | |
0.998 R² (0.997 R² .. 0.999 R²) | |
mean 17.32 ns (17.05 ns .. 17.66 ns) | |
std dev 1.042 ns (863.2 ps .. 1.458 ns) | |
variance introduced by outliers: 80% (severely inflated) | |
benchmarking integral/mine 2 | |
time 17.10 ns (16.64 ns .. 17.63 ns) | |
0.995 R² (0.993 R² .. 0.998 R²) | |
mean 16.92 ns (16.56 ns .. 17.34 ns) | |
std dev 1.269 ns (1.064 ns .. 1.529 ns) | |
variance introduced by outliers: 86% (severely inflated) | |
benchmarking integral/mine 3 | |
time 18.29 ns (17.80 ns .. 18.84 ns) | |
0.996 R² (0.994 R² .. 0.998 R²) | |
mean 18.20 ns (17.89 ns .. 18.51 ns) | |
std dev 1.065 ns (849.4 ps .. 1.367 ns) | |
variance introduced by outliers: 79% (severely inflated) | |
benchmarking integral/not mine 1 | |
time 18.25 ns (17.69 ns .. 18.74 ns) | |
0.994 R² (0.992 R² .. 0.996 R²) | |
mean 18.32 ns (17.86 ns .. 18.75 ns) | |
std dev 1.481 ns (1.254 ns .. 1.816 ns) | |
variance introduced by outliers: 88% (severely inflated) | |
benchmarking integral/not mine 2 | |
time 18.68 ns (18.18 ns .. 19.38 ns) | |
0.989 R² (0.982 R² .. 0.996 R²) | |
mean 19.20 ns (18.62 ns .. 19.95 ns) | |
std dev 2.227 ns (1.709 ns .. 2.807 ns) | |
variance introduced by outliers: 94% (severely inflated) | |
benchmarking integral/not mine 3 | |
time 17.82 ns (17.43 ns .. 18.23 ns) | |
0.996 R² (0.995 R² .. 0.998 R²) | |
mean 17.93 ns (17.57 ns .. 18.31 ns) | |
std dev 1.264 ns (966.6 ps .. 1.845 ns) | |
variance introduced by outliers: 85% (severely inflated) |
This file contains 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 Criterion.Main | |
import qualified Data.ByteString.Lazy as DBSL | |
import qualified Data.ByteString.Lazy.Char8 as DBSLC | |
import qualified Text.Show.ByteString as TSBS | |
isIntegral :: Float -> Bool | |
isIntegral = DBSL.isSuffixOf (DBSLC.pack ".0") . TSBS.show | |
isIntegral' :: Float -> Bool | |
isIntegral' x = x == fromInteger (round x) | |
mapII :: [Float] -> [Bool] | |
mapII = map isIntegral | |
mapII' :: [Float] -> [Bool] | |
mapII' = map isIntegral' | |
main :: IO () | |
main = defaultMain [ | |
bgroup "integral" [ bench "mine 1" $ whnf mapII [1..1000] | |
, bench "mine 2" $ whnf mapII [1..1000000] | |
, bench "mine 3" $ whnf mapII [1..1000000000] | |
, bench "not mine 1" $ whnf mapII' [1..1000] | |
, bench "not mine 2" $ whnf mapII' [1..1000000] | |
, bench "not mine 3" $ whnf mapII' [1..1000000000] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment