packages feed

tracy-profiler 0.1.2.0 → 0.1.2.1

raw patch · 6 files changed

+49/−26 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ System.Tracy.FFI: shutdownProfiler :: IO ()
+ System.Tracy.FFI: startupProfiler :: IO ()
- System.Tracy: withProfiler :: a -> a
+ System.Tracy: withProfiler :: MonadUnliftIO m => m a -> m a

Files

CHANGELOG.md view
@@ -6,6 +6,10 @@ and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## 0.1.2.1 - 2025-11-02++- Fix `-enable` build without having libtracyclient installed.+ ## 0.1.2.0 - 2025-11-01  - Fixed byte order in IsLabel Color instance.
README.md view
@@ -12,29 +12,23 @@ sudo apt install libtracy-dev tracy-capture tracy-profiler ``` -Or you can [download] and build one yourself and point your project to it:--[download]: https://github.com/wolfpld/tracy/--```sh-mkdir -p upstream-cd upstream && git clone --recursive https://github.com/wolfpld/tracy-cmake -B upstream/tracy/build -S upstream/tracy \-  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \-  -DTRACY_ONLY_LOCALHOST=ON \-  -DTRACY_ENABLE=ON \-  -DTRACY_MANUAL_LIFETIME=ON \-  -DTRACY_DELAYED_INIT=ON-cmake --build upstream/tracy/build --config Release-```+Or you can download and build one yourself and point your project to it:  ```yaml+# stack.yaml extra-lib-dirs:-- upstream/tracy/build+- upstream/_build/library extra-include-dirs: - upstream/tracy/public/tracy ``` +You can use the provided Makefile that will do the thing:+```sh+make all # fetch and build stuff+make test # run the example+_build/profiler/tracy-profiler & disown # launch the profiler GUI+```+ This way you can customize configuration. Make sure you update package flags to match. @@ -63,7 +57,6 @@ Use the functions from `System.Tracy` and `System.Tracy.Zone` to collect data:  ```haskell-{-# LANGUAGE CPP #-}               -- __LINE__ and __FILE__ macros {-# LANGUAGE MagicHash #-}         -- "static strings"# {-# LANGUAGE OverloadedLabels #-}  -- #fuchsia colors {-# LANGUAGE OverloadedStrings #-} -- "yes"
src/System/Tracy/FFI/Types.hsc view
@@ -7,9 +7,6 @@ import WebColor.Labels import GHC.OverloadedLabels -#define TRACY_ENABLE-#include <tracy/TracyC.h>- {- | Packed 32-bit color  Hex literals can be used as @0xRRGGBB@.@@ -39,6 +36,9 @@   , color    :: Color   } +#ifdef TRACY_ENABLE+#include "TracyC.h"+ instance Storable SourceLocationData where   sizeOf (~_undef) = (#size struct ___tracy_source_location_data) @@ -58,6 +58,8 @@     (#poke struct ___tracy_source_location_data, file) ptr file     (#poke struct ___tracy_source_location_data, line) ptr line     (#poke struct ___tracy_source_location_data, color) ptr color++#endif  newtype TracyCZoneCtx = TracyCZoneCtx (Ptr TracyCZoneCtx)   deriving (Show)
src/System/Tracy/Zone.hs view
@@ -18,16 +18,16 @@  import Control.Monad.IO.Class (MonadIO(..)) import Data.ByteString (ByteString)-import Data.ByteString.Unsafe (unsafeUseAsCStringLen) import Data.Text (Text)-import Data.Text.Foreign qualified as Text import Data.Word-import Foreign.C.ConstPtr (ConstPtr(..))  #ifdef TRACY_ENABLE import Control.Exception (bracket) import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO) import Data.ByteString.Char8 qualified as ByteString+import Data.ByteString.Unsafe (unsafeUseAsCStringLen)+import Data.Text.Foreign qualified as Text+import Foreign.C.ConstPtr (ConstPtr(..)) import GHC.Stack import GHC.Stack.Types qualified as GHC @@ -39,10 +39,11 @@ #endif -- !unsafe #endif++import System.Tracy.FFI qualified as FFI -- enable #endif -import System.Tracy.FFI qualified as FFI import System.Tracy.FFI.Types qualified as FFI  {- | Allocate SrcLoc and run a Zone with it.@@ -159,6 +160,9 @@   -> Maybe ByteString   -> FFI.Color   -> IO FFI.SrcLoc+#ifndef TRACY_ENABLE+allocSrcloc _line _source _function _name _col = pure $ FFI.SrcLoc 0+#else allocSrcloc line source function name_ col =   unsafeUseAsCStringLen source \(sourcePtr, sourceSz) ->   unsafeUseAsCStringLen function \(functionPtr, functionSz) ->@@ -177,6 +181,7 @@             (ConstPtr functionPtr) (fromIntegral functionSz)             (ConstPtr namePtr) (fromIntegral nameSz)             col+#endif  {- TODO: Wrap emitZoneBegin @@ -189,21 +194,41 @@ -}  {-# INLINE text #-}+#ifndef TRACY_ENABLE+text :: MonadIO m => Text -> m ()+text _txt = pure ()+#else text :: (MonadIO m, ?zoneCtx :: FFI.TracyCZoneCtx) => Text -> m () text txt = liftIO $   Text.withCStringLen txt \(txtPtr, txtSz) ->     FFI.emitZoneText ?zoneCtx (ConstPtr txtPtr) (fromIntegral txtSz)+#endif  {-# INLINE name #-}+#ifndef TRACY_ENABLE+name :: MonadIO m => Text -> m ()+name _txt = pure ()+#else name :: (MonadIO m, ?zoneCtx :: FFI.TracyCZoneCtx) => Text -> m () name txt = liftIO $   Text.withCStringLen txt \(txtPtr, txtSz) ->     FFI.emitZoneName ?zoneCtx (ConstPtr txtPtr) (fromIntegral txtSz)+#endif  {-# INLINE color #-}+#ifndef TRACY_ENABLE+color :: MonadIO m => FFI.Color -> m ()+color _col = pure ()+#else color :: (MonadIO m, ?zoneCtx :: FFI.TracyCZoneCtx) => FFI.Color -> m () color col = liftIO $ FFI.emitZoneColor ?zoneCtx col+#endif  {-# INLINE value #-}+#ifndef TRACY_ENABLE+value :: MonadIO m => Word64 -> m ()+value _val = pure ()+#else value :: (MonadIO m, ?zoneCtx :: FFI.TracyCZoneCtx) => Word64 -> m () value val = liftIO $ FFI.emitZoneValue ?zoneCtx val+#endif
test/Readme.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-}               -- __LINE__ and __FILE__ macros {-# LANGUAGE MagicHash #-}         -- "static strings"# {-# LANGUAGE OverloadedLabels #-}  -- #fuchsia colors {-# LANGUAGE OverloadedStrings #-} -- "yes"
tracy-profiler.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           tracy-profiler-version:        0.1.2.0+version:        0.1.2.1 synopsis:       Haskell bindings for Tracy frame profiler category:       Profiling homepage:       https://github.com/haskell-game/tracy-profiler#readme