- why is it that the haskell Text.CSV version is always around twice as slow?
- how can I use
;
as a column separator in the haskell Text.CSV version?
Last active
September 16, 2019 21:23
-
-
Save docteurklein/bf3174494c96431e4bf6329d5479f2bb 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
import Data.Char | |
import Data.Csv | |
import qualified Data.ByteString.Lazy.Char8 as BL | |
main = do | |
BL.putStrLn $ encodeWith defaultEncodeOptions { | |
encDelimiter = fromIntegral (ord ';') | |
} $ [ | |
("id", "group")] ++ [ | |
(("id-" ++ show x ++ show y), "group-" ++ show x) | |
| x <- [1..90], y <- [1..222]] |
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
import Text.CSV | |
main = do | |
putStrLn $ printCSV [[ | |
"col1", | |
"col2"]] | |
putStrLn $ printCSV [[ | |
"id-" ++ show x ++ show y, | |
"group-" ++ show x] | x <- [1..90], y <- [1..222]] | |
-- ghc -dynamic csv.hs | |
-- time ./csv | |
-- ./csv 0.10s user 0.06s system 99% cpu 0.156 total |
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
<?php declare(strict_types=1); | |
$fd = fopen('php://output', 'a'); | |
fputcsv($fd, [ | |
'col1', | |
'col2', | |
], ';'); | |
for($i=1; $i <= 90; $i++) { | |
for($j=1; $j <= 222; $j++) { | |
fputcsv($fd, [ | |
"id-$i$j", | |
"group-$i", | |
], ';'); | |
} | |
} | |
// time php csv.php | |
// php csv.php 0.02s user 0.07s system 99% cpu 0.090 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment