Created
April 23, 2023 12:02
-
-
Save ugovaretto/735c7098f08ea11a574feaba3cee4189 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
cabal-version: 3.4 | |
-- The cabal-version field refers to the version of the .cabal specification, | |
-- and can be different from the cabal-install (the tool) version and the | |
-- Cabal (the library) version you are using. As such, the Cabal (the library) | |
-- version used must be equal or greater than the version stated in this field. | |
-- Starting from the specification version 2.2, the cabal-version field must be | |
-- the first thing in the cabal file. | |
-- Initial package description 'y' generated by | |
-- 'cabal init'. For further documentation, see: | |
-- http://haskell.org/cabal/users-guide/ | |
-- | |
-- The name of the package. | |
name: y | |
-- The package version. | |
-- See the Haskell package versioning policy (PVP) for standards | |
-- guiding when and how versions should be incremented. | |
-- https://pvp.haskell.org | |
-- PVP summary: +-+------- breaking API changes | |
-- | | +----- non-breaking API additions | |
-- | | | +--- code changes with no API change | |
version: 0.1.0.0 | |
-- A short (one-line) description of the package. | |
-- synopsis: | |
-- A longer description of the package. | |
-- description: | |
-- The license under which the package is released. | |
license: BSD-3-Clause | |
-- The file containing the license text. | |
license-file: LICENSE | |
-- The package author(s). | |
author: Ugo Varetto | |
-- An email address to which users can send suggestions, bug reports, and patches. | |
maintainer: ugovaretto@gmail.com | |
-- A copyright notice. | |
-- copyright: | |
category: System | |
build-type: Simple | |
-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README. | |
extra-doc-files: CHANGELOG.md | |
-- Extra source files to be distributed with the package, such as examples, or a tutorial module. | |
-- extra-source-files: | |
common warnings | |
ghc-options: -Wall | |
executable y | |
-- Import common warning flags. | |
import: warnings | |
-- .hs or .lhs file containing the Main module. | |
main-is: heic2jpeg.hs | |
-- Modules included in this executable, other than Main. | |
-- other-modules: | |
-- LANGUAGE extensions used by modules in this package. | |
-- other-extensions: | |
-- Other library packages from which modules are imported. | |
build-depends: base ^>=4.18.0.0, | |
directory, | |
filepath, | |
process, | |
monad-parallel | |
-- Directories containing source files. | |
hs-source-dirs: app | |
-- Base language which the package is written in. | |
default-language: GHC2021 | |
ghc-options: | |
-O3 | |
-threaded | |
-rtsopts | |
-with-rtsopts=-s |
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
-- Parallel conversion of HEIC to JPEG | |
import System.Directory | |
import System.FilePath | |
import Control.Monad | |
import System.Process | |
import Data.Char | |
import System.Environment | |
import qualified Control.Monad.Parallel as P | |
main :: IO () | |
main = do | |
args <- getArgs | |
let dir = head args | |
c <- listDirectory dir | |
f <- filterM (\x -> return (map toLower (snd(splitExtension (dir ++ "/" ++ x))) == ".heic")) c | |
_ <- P.mapM (\y -> let x = dir ++ "/" ++ y | |
in callProcess "convert" [x, (dropExtension x) ++ ".jpg"]) f | |
return () |
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
Converting 27 images from HEIC to JPEG using imagemagick's convert. | |
------------------------------------------------------------------- | |
* Serial (Control.Monad.mapM) | |
638,360 bytes allocated in the heap | |
563,056 bytes copied during GC | |
59,256 bytes maximum residency (28 sample(s)) | |
29,168 bytes maximum slop | |
6 MiB total memory in use (0 MiB lost due to fragmentation) | |
Tot time (elapsed) Avg pause Max pause | |
Gen 0 0 colls, 0 par 0.000s 0.000s 0.0000s 0.0000s | |
Gen 1 28 colls, 0 par 0.013s 0.013s 0.0005s 0.0008s | |
TASKS: 4 (1 bound, 3 peak workers (3 total), using -N1) | |
SPARKS: 0 (0 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) | |
INIT time 0.001s ( 0.002s elapsed) | |
MUT time 0.029s ( 54.509s elapsed) | |
GC time 0.013s ( 0.013s elapsed) | |
EXIT time 0.000s ( 0.007s elapsed) | |
Total time 0.044s ( 54.530s elapsed) | |
Alloc rate 21,872,924 bytes per MUT second | |
Productivity 66.8% of total user, 100.0% of total elapsed | |
----------------- | |
real 0m54.793s | |
----------------- | |
user 1m2.535s | |
sys 0m11.057s | |
* Parallel (Control.Monad.Parallel.mapM) | |
1,474,456 bytes allocated in the heap | |
92,680 bytes copied during GC | |
946,880 bytes maximum residency (3 sample(s)) | |
29,216 bytes maximum slop | |
7 MiB total memory in use (0 MiB lost due to fragmentation) | |
Tot time (elapsed) Avg pause Max pause | |
Gen 0 0 colls, 0 par 0.000s 0.000s 0.0000s 0.0000s | |
Gen 1 3 colls, 0 par 0.009s 0.045s 0.0151s 0.0439s | |
TASKS: 30 (1 bound, 29 peak workers (29 total), using -N1) | |
SPARKS: 0 (0 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled) | |
INIT time 0.000s ( 0.000s elapsed) | |
MUT time 0.030s ( 12.520s elapsed) | |
GC time 0.009s ( 0.045s elapsed) | |
EXIT time 0.004s ( 0.004s elapsed) | |
Total time 0.044s ( 12.570s elapsed) | |
Alloc rate 48,486,720 bytes per MUT second | |
Productivity 69.8% of total user, 99.6% of total elapsed | |
----------------- | |
real 0m12.608s | |
----------------- | |
user 4m19.597s | |
sys 0m18.936s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment