tracy-profiler 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+51/−24 lines, 4 filesdep +unliftio-corePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: unliftio-core
API changes (from Hackage documentation)
- System.Tracy: withProfiler :: IO a -> IO a
+ System.Tracy: withProfiler :: a -> a
- System.Tracy: withSrcLoc_ :: Word32 -> ByteString -> ByteString -> Color -> ((?zoneCtx :: TracyCZoneCtx) => IO a) -> IO a
+ System.Tracy: withSrcLoc_ :: MonadUnliftIO m => Word32 -> ByteString -> ByteString -> Color -> ((?zoneCtx :: TracyCZoneCtx) => m a) -> m a
- System.Tracy.Zone: withSrcLoc_ :: Word32 -> ByteString -> ByteString -> Color -> ((?zoneCtx :: TracyCZoneCtx) => IO a) -> IO a
+ System.Tracy.Zone: withSrcLoc_ :: MonadUnliftIO m => Word32 -> ByteString -> ByteString -> Color -> ((?zoneCtx :: TracyCZoneCtx) => m a) -> m a
Files
- CHANGELOG.md +5/−0
- src/System/Tracy.hs +23/−15
- src/System/Tracy/Zone.hs +20/−8
- tracy-profiler.cabal +3/−1
CHANGELOG.md view
@@ -6,6 +6,11 @@ and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## 0.1.1.0 - 2025-10-30++- Fixes for copypasta in `#ifndef TRACE_ENABLE` sections.+- `withProfiler` and `withSrcLoc_` now require `MonadUnliftIO`.+ ## 0.1.0.0 - 2025-10-30 Initial release.
src/System/Tracy.hs view
@@ -37,34 +37,41 @@ , Color ) where -import Control.Concurrent (threadDelay) import Control.Monad (void) import Control.Monad.IO.Class (MonadIO(..))-import Data.Maybe (fromMaybe) import Data.Text (Text)+import GHC.Exts (Addr#)++#if defined(TRACY_ENABLE)+import Control.Concurrent (threadDelay)+import Data.Maybe (fromMaybe) import Data.Text.Foreign qualified as Text import Foreign (nullPtr) import Foreign.C.ConstPtr (ConstPtr(..))-import GHC.Exts (Ptr(..), Addr#)+import GHC.Exts(Ptr(..)) import System.Timeout (timeout)- import System.Tracy.FFI qualified as FFI+#endif+ import System.Tracy.FFI.Types (Color, PlotFormat(..)) import System.Tracy.Zone qualified as Zone #if defined(TRACY_ENABLE) && defined(TRACY_MANUAL_LIFETIME) import Control.Exception (bracket_)+import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO) #endif {- | Start/stop profiler when TRACY_MANUAL_LIFETIME is enabled. Otherwise does nothing. -}-withProfiler :: IO a -> IO a-withProfiler action = #if defined(TRACY_ENABLE) && defined(TRACY_MANUAL_LIFETIME)- bracket_ FFI.startupProfiler FFI.shutdownProfiler action+withProfiler :: MonadUnliftIO m => m a -> m a+withProfiler action =+ withRunInIO \run ->+ bracket_ FFI.startupProfiler FFI.shutdownProfiler (run action) #else- action+withProfiler :: a -> a+withProfiler = id #endif {- | Check whether the profiler is connected.@@ -137,7 +144,7 @@ #if defined(TRACY_ENABLE) frameMarkStart name = liftIO $ FFI.emitFrameMarkStart (ConstPtr $ Ptr name) #else-frameMarkStart = pure ()+frameMarkStart _name = pure () #endif {-# INLINE frameMarkEnd #-}@@ -145,7 +152,7 @@ #if defined(TRACY_ENABLE) frameMarkEnd name = liftIO $ FFI.emitFrameMarkEnd (ConstPtr $ Ptr name) #else-frameMarkEnd = pure ()+frameMarkEnd _name = pure () #endif -- TODO: nicer wrapper for emitFrameImage@@ -167,7 +174,7 @@ Text.withCStringLen txt \(txtPtr, txtSz) -> FFI.emitMessageC (ConstPtr txtPtr) (fromIntegral txtSz) color 0 #else-messageC _txt = pure ()+messageC _color _txt = pure () #endif @@ -195,7 +202,7 @@ plot name val = liftIO $ FFI.emitPlot (ConstPtr (Ptr name)) val #else-plot _name = pure ()+plot _name _val = pure () #endif {-# INLINE plotFloat #-}@@ -204,7 +211,7 @@ plotFloat name val = liftIO $ FFI.emitPlotFloat (ConstPtr (Ptr name)) val #else-plotFloat _name = pure ()+plotFloat _name _val = pure () #endif {-# INLINE plotInt #-}@@ -212,12 +219,13 @@ plotInt = plotIntegral {-# INLINE plotIntegral #-}-plotIntegral :: (Integral a, MonadIO m) => Addr# -> a -> m () #if defined(TRACY_ENABLE)+plotIntegral :: (Integral a, MonadIO m) => Addr# -> a -> m () plotIntegral name val = liftIO $ FFI.emitPlotInt (ConstPtr (Ptr name)) (fromIntegral val) #else-plotIntegral _name = pure ()+plotIntegral :: Monad m => Addr# -> a -> m ()+plotIntegral _name _val = pure () #endif {-# INLINE plotConfig #-}
src/System/Tracy/Zone.hs view
@@ -15,7 +15,6 @@ , allocSrcloc ) where -import Control.Exception (bracket) import Control.Monad.IO.Class (MonadIO(..)) import Data.ByteString (ByteString) import Data.ByteString.Unsafe (unsafeUseAsCStringLen)@@ -24,6 +23,11 @@ import Data.Word import Foreign.C.ConstPtr (ConstPtr(..)) +#ifdef TRACY_ENABLE+import Control.Exception (bracket)+import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO)+#endif+ import System.Tracy.FFI qualified as FFI import System.Tracy.FFI.Types qualified as FFI @@ -40,22 +44,30 @@ -- ... @ -}-withSrcLoc_- :: Word32+{-# INLINE withSrcLoc_ #-}+withSrcLoc_ ::+#ifndef TRACY_ENABLE+ ()+#else+ (MonadUnliftIO m)+#endif+ => Word32 -> ByteString -> ByteString -> FFI.Color- -> ((?zoneCtx :: FFI.TracyCZoneCtx) => IO a)- -> IO a+ -> ((?zoneCtx :: FFI.TracyCZoneCtx) => m a)+ -> m a #ifndef TRACY_ENABLE-withSrcLoc_ _line _file _function action = action+withSrcLoc_ _line _file _function _col action =+ let ?zoneCtx = FFI.nullTracyCZoneCtx+ in action #else-withSrcLoc_ line file function col action = do+withSrcLoc_ line file function col action = withRunInIO \run -> do srcloc <- allocSrcloc line file function Nothing col bracket (FFI.emitZoneBeginAlloc srcloc 1) FFI.emitZoneEnd- (\ctx -> let ?zoneCtx = ctx in action)+ (\ctx -> run $ let ?zoneCtx = ctx in action) #endif {- | Prepare a single-use location identifier
tracy-profiler.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: tracy-profiler-version: 0.1.0.0+version: 0.1.1.0 synopsis: Haskell bindings for Tracy frame profiler category: Profiling homepage: https://github.com/haskell-game/tracy-profiler#readme@@ -76,6 +76,7 @@ base >=4.16 && <5 , bytestring , text >=2.0 && <3+ , unliftio-core , webcolor-labels default-language: GHC2021 if flag(manual_lifetime)@@ -114,4 +115,5 @@ , random , text , tracy-profiler+ , unliftio-core default-language: GHC2021