[commit: packages/time] format-widths, master, posix-perf, tasty: Replace benchmark stanza with separate time-bench package (fe018aa)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:18:59 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: format-widths,master,posix-perf,tasty
Link       : http://git.haskell.org/packages/time.git/commitdiff/fe018aab2322fbac6a928e19a4310013622ed7da

>---------------------------------------------------------------

commit fe018aab2322fbac6a928e19a4310013622ed7da
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Mon Dec 5 22:46:03 2016 -0800

    Replace benchmark stanza with separate time-bench package


>---------------------------------------------------------------

fe018aab2322fbac6a928e19a4310013622ed7da
 benchmark/Main.hs          | 44 ++++++++++++++++++++++++++------
 benchmark/time-bench.cabal | 41 ++++++++++++++++++++++++++++++
 time.cabal                 | 63 ----------------------------------------------
 3 files changed, 77 insertions(+), 71 deletions(-)

diff --git a/benchmark/Main.hs b/benchmark/Main.hs
index e64a3cf..1be1b67 100644
--- a/benchmark/Main.hs
+++ b/benchmark/Main.hs
@@ -1,19 +1,47 @@
+{-# LANGUAGE PackageImports #-}
 module Main where
 
--------------------------------------------------------------------------------
+import  Criterion.Main
+import  Data.Time.Clock
+import  Data.Time.Calendar
+import  Data.Time.Clock.POSIX
+import  Data.Time.LocalTime
+import  Data.Time.Format
+import  Data.Time.Clock
 
-import     Criterion.Main
-import     Data.Time.Clock.POSIX
-import     Data.Time
+import qualified "time" Data.Time.Clock       as O
+import qualified "time" Data.Time.Clock.POSIX as O
+import qualified "time" Data.Time.LocalTime   as O
+import qualified "time" Data.Time.Format      as O
+import qualified "time" Data.Time.Clock       as O
 
 main :: IO ()
 main = do
     getCurrentTime >>= print
-    getPOSIXTime >>= print . posixSecondsToUTCTime
+    O.getCurrentTime >>= print
+    getPOSIXTime >>= print . posixToUTCTime
+    O.getPOSIXTime >>= print . O.posixSecondsToUTCTime
+    getZonedTime >>= print
+    O.getZonedTime >>= print
+
+    tz <- getCurrentTimeZone
+    ct <- getCurrentTime
+    otz <- O.getCurrentTimeZone
+    oct <- O.getCurrentTime
+
     defaultMain
-        [ bgroup "time"
-            [ bench "UTCTime" $ whnfIO getCurrentTime
-            , bench "POSIXTime" $ whnfIO getPOSIXTime
+        [ bgroup "new"
+            [ bench "getCurrentTime" $ nfIO getCurrentTime
+            , bench "getPOSIXTime" $ nfIO getPOSIXTime
+            , bench "getZonedTime" $ nfIO getZonedTime
+            , bench "formatTime" $ nf (formatTime defaultTimeLocale "%a, %_d %b %Y %H:%M:%S %Z") ct
+            ]
+        ,
+          bgroup "old"
+            [ bench "getCurrentTime" $ nfIO O.getCurrentTime
+            , bench "getPOSIXTime" $ nfIO O.getPOSIXTime
+            , bench "getZonedTime" $ nfIO O.getZonedTime
+            , bench "formatTime" $ nf (O.formatTime O.defaultTimeLocale "%a, %_d %b %Y %H:%M:%S %Z") oct
             ]
         ]
 
diff --git a/benchmark/time-bench.cabal b/benchmark/time-bench.cabal
new file mode 100644
index 0000000..0a94ad4
--- /dev/null
+++ b/benchmark/time-bench.cabal
@@ -0,0 +1,41 @@
+name:           time-bench
+version:        0.1.0.0
+author:         Winter
+homepage:       https://github.com/haskell/time
+bug-reports:    https://github.com/haskell/time/issues
+cabal-version:  >=1.10
+build-type:          Simple
+
+
+executable time-bench
+    hs-source-dirs: ../lib, .
+    main-is: Main.hs
+    default-language: Haskell2010
+    if impl(ghc)
+        default-extensions:
+            Rank2Types
+            DeriveDataTypeable
+            StandaloneDeriving
+        cpp-options: -DLANGUAGE_Rank2Types -DLANGUAGE_DeriveDataTypeable -DLANGUAGE_StandaloneDeriving
+    else
+        if impl(hugs)
+            default-extensions: Rank2Types
+            cpp-options: -DLANGUAGE_Rank2Types
+    ghc-options: -Wall -fwarn-tabs
+    build-depends:
+        base >= 4.7 && < 5,
+        deepseq >= 1.1,
+        time,
+        criterion
+    if os(windows)
+        build-depends: Win32
+    default-extensions:    CPP
+    c-sources: ../lib/cbits/HsTime.c
+    include-dirs: ../lib/include
+    if os(windows)
+        install-includes:
+            HsTime.h
+    else
+        install-includes:
+            HsTime.h
+            HsTimeConfig.h
diff --git a/time.cabal b/time.cabal
index 8f791e8..99ed765 100644
--- a/time.cabal
+++ b/time.cabal
@@ -151,66 +151,3 @@ test-suite tests
         Test.AddDays
         Test.AddDaysRef
         Test.TestUtil
-        
-benchmark bench
-    hs-source-dirs: lib, benchmark
-    default-language: Haskell2010
-    type: exitcode-stdio-1.0
-    main-is: Main.hs
-    if impl(ghc)
-        default-extensions:
-            Rank2Types
-            DeriveDataTypeable
-            StandaloneDeriving
-        cpp-options: -DLANGUAGE_Rank2Types -DLANGUAGE_DeriveDataTypeable -DLANGUAGE_StandaloneDeriving
-    else
-        if impl(hugs)
-            default-extensions: Rank2Types
-            cpp-options: -DLANGUAGE_Rank2Types
-    ghc-options: -Wall -fwarn-tabs
-    build-depends:
-            base >= 4.7 && < 5
-        ,   deepseq >= 1.1
-        ,   criterion >= 1.0.2.0
-        ,   time
-
-    if os(windows)
-        build-depends: Win32
-    other-modules:
-        Data.Time.Calendar,
-        Data.Time.Calendar.MonthDay,
-        Data.Time.Calendar.OrdinalDate,
-        Data.Time.Calendar.WeekDate,
-        Data.Time.Calendar.Julian,
-        Data.Time.Calendar.Easter,
-        Data.Time.Clock,
-        Data.Time.Clock.POSIX,
-        Data.Time.Clock.TAI,
-        Data.Time.LocalTime,
-        Data.Time.Format,
-        Data.Time
-    default-extensions:    CPP
-    c-sources: lib/cbits/HsTime.c
-    other-modules:
-        Data.Time.Calendar.Private,
-        Data.Time.Calendar.Days,
-        Data.Time.Calendar.Gregorian,
-        Data.Time.Calendar.JulianYearDay,
-        Data.Time.Clock.Scale,
-        Data.Time.Clock.UTC,
-        Data.Time.Clock.CTimeval,
-        Data.Time.Clock.CTimespec,
-        Data.Time.Clock.UTCDiff,
-        Data.Time.LocalTime.TimeZone,
-        Data.Time.LocalTime.TimeOfDay,
-        Data.Time.LocalTime.LocalTime,
-        Data.Time.Format.Parse
-        Data.Time.Format.Locale
-    include-dirs: lib/include
-    if os(windows)
-        install-includes:
-            HsTime.h
-    else
-        install-includes:
-            HsTime.h
-            HsTimeConfig.h



More information about the ghc-commits mailing list