Skip to content

Instantly share code, notes, and snippets.

View tibbe's full-sized avatar

Johan Tibell tibbe

View GitHub Profile
@tibbe
tibbe / geopandas-2108-repro.ipynb
Last active September 20, 2021 09:48
geopandas #2108 repro.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tibbe
tibbe / he2015-examples.hs
Created October 29, 2015 09:51
Benchmarks from the Haskell eXchange talk on High performance programming in Haskell
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
module Main (main) where
import Control.DeepSeq
import Criterion.Main
import GHC.Generics (Generic)
import Prelude hiding (replicate, sum)
data List = Cons Int List | Nil
import Control.Monad
import Control.Concurrent
import Data.Int
import System.Environment
sendSidewards :: Chan Int -> Chan Int -> IO ()
sendSidewards from to = do
n <- readChan from
writeChan to n
sendSidewards from to
./accelerate-0.14.0.0/Data/Array/Accelerate/Array/Data.hs:43:import GHC.Prim (newPinnedByteArray#, byteArrayContents#,
./accelerate-0.14.0.0/Data/Array/Accelerate/Array/Data.hs:631:uArrayPtr (UArray _ _ _ ba) = Ptr (byteArrayContents# ba)
./accelerate-0.14.0.0/Data/Array/Accelerate/Array/Data.hs:641: (# s', ba #) -> (# s', Ptr (byteArrayContents# ba) #)
./ajhc-0.8.0.10/src/RawFiles.hs:60: \ case action (byteArrayContents# barr#) s of { (# s, r #) ->\n\
./base-4.7.0.0/Foreign/Marshal/Alloc.hs:124: let addr = Ptr (byteArrayContents# barr#) in
./base-4.7.0.0/Foreign/Marshal/Alloc.hs:135: let addr = Ptr (byteArrayContents# barr#) in
./base-4.7.0.0/GHC/Conc/Windows.hs:99: asyncRead fd isSock len ((Ptr (byteArrayContents# (unsafeCoerce# bufB))) `plusPtr` off)
./base-4.7.0.0/GHC/Conc/Windows.hs:103: asyncWrite fd isSock len ((Ptr (byteArrayContents# (unsafeCoerce# bufB))) `plusPtr` off)
./base-4.7.0.0/GHC/ForeignPtr.hs:163: (# s', ForeignPtr (byteArrayContents# (unsafeCoerce# m
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Test where
import GHC.Exts
add :: MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
add mba ix n s = fetchAddIntArray# mba ix n s
nand :: MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
# One time setup for hacking on cabal-install
git clone https://github.com/haskell/cabal.git
cd cabal/cabal-install
cabal sandbox init
cabal sandbox add-source ../Cabal
cabal install --only-dep
# Iterate
cabal build
Full Data.HashMap.Base 361 739926 0.2 0.5 0.4 0.9
Leaf-coll Data.HashMap.Base 368 101 0.0 0.0 0.0 0.0
BitmapIndexed-replace Data.HashMap.Base 364 226745 0.1 0.1 0.1 0.2
Leaf-coll Data.HashMap.Base 367 87870 0.0 0.0 0.0 0.0
BitmapIndexed-grow Data.HashMap.Base 366 25452 0.0 0.0 0.0 0.0
Leaf-no-coll Data.HashMap.Base 365 81709 0.0 0.1 0.0 0.1
Leaf-no-coll Data.HashMap.Base 363 6060 0.0 0.0 0.0 0.0
BitmapIndexed-grow Data.HashMap.Base 362 203515 0.1 0.1 0.1 0.1
BitmapIndexed-replace Data.HashMap
@tibbe
tibbe / ghc-clang-wrapper
Last active January 3, 2016 10:19 — forked from mzero/ghc-clang-wrapper
Strip -nodefaultlibs flag to avoid warning This removes this warning: clang: warning: argument unused during compilation: '-nodefaultlibs'
#!/bin/sh
inPreprocessorMode () {
hasE=0
hasU=0
hasT=0
for arg in "$@"
do
if [ 'x-E' = "x$arg" ]; then hasE=1; fi
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi
@tibbe
tibbe / build-cabal.sh
Created April 26, 2013 21:05
Jenkins build script for Cabal and cabal-install
export GHC=$compiler
cd Cabal
which cabal
[ ! -d .cabal-sandbox ] && cabal sandbox init
cabal clean
cabal install -j --only-dependencies --enable-tests -w $compiler
cabal configure --enable-tests -w $compiler
cabal build
cabal test --test-option='--jxml=$test-suite.junit.xml' --test-option=--plain
cabal sdist
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
module Longest where
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as BC
import Data.Word (Word8)
-- using custom data type (only works for 2 elements)
data TwoQueue = Empty