Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Last active October 18, 2020 11:15
Show Gist options
  • Save Shimuuar/82df518aee412de92bc48487945aea7b to your computer and use it in GitHub Desktop.
Save Shimuuar/82df518aee412de92bc48487945aea7b to your computer and use it in GitHub Desktop.
summation performace
kbn
kb2
*.hi
*.o
*.data
TAGS
naive
onlygen
{-# LANGUAGE NumDecimals #-}
import qualified Data.Vector.Unboxed as U
import qualified Numeric.Sum as Sum
import qualified System.Random.MWC as MWC
main :: IO ()
main = do
g <- MWC.create
vec <- MWC.uniformVector g 1e8
print $ Sum.sumVector Sum.kb2 (vec :: U.Vector Double)
{-# LANGUAGE NumDecimals #-}
import qualified Data.Vector.Unboxed as U
import qualified Numeric.Sum as Sum
import qualified System.Random.MWC as MWC
main :: IO ()
main = do
g <- MWC.create
vec <- MWC.uniformVector g 1e8
print $ Sum.sumVector Sum.kbn (vec :: U.Vector Double)
.PHONY: all clean report
all: naive kb2 kbn onlygen
report: naive.data kb2.data kbn.data onlygen.data
clean:
rm -rfv kbn naive kb2 onlygen *.o *.hi *.data *.old
%: %.hs
ghc -g --make -O2 $<
%.data: %
rm -f $@
perf record -o $@ ./$<
{-# LANGUAGE NumDecimals #-}
import qualified Data.Vector.Unboxed as U
import qualified Numeric.Sum as Sum
import qualified System.Random.MWC as MWC
main :: IO ()
main = do
g <- MWC.create
vec <- MWC.uniformVector g 1e8
print $ U.sum (vec :: U.Vector Double)
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed as U
import qualified Numeric.Sum as Sum
import qualified System.Random.MWC as MWC
main :: IO ()
main = do
g <- MWC.create
vec :: U.Vector Double <- MWC.uniformVector g 1e8
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment