From 87815edbab70302793fb83259fedc1ae9004d172 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 21 Dec 2024 16:37:24 +0530 Subject: Optimize initialization time --- src/Chelleport/Context.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/Chelleport/Context.hs') diff --git a/src/Chelleport/Context.hs b/src/Chelleport/Context.hs index 15c0b6a..3c2c850 100644 --- a/src/Chelleport/Context.hs +++ b/src/Chelleport/Context.hs @@ -3,6 +3,8 @@ module Chelleport.Context (initializeContext) where import Chelleport.Types import Data.ByteString (ByteString) import Data.FileEmbed (embedFileRelative) +-- import Data.Time.Clock.System +-- import qualified Debug.Trace as Debug import Foreign.C (CFloat) import qualified Graphics.X11 as X11 import SDL (($=)) @@ -15,10 +17,18 @@ windowOpacity = 0.5 fontSize :: Int fontSize = 24 +-- benchmark :: String -> IO a -> IO a +-- benchmark msg m = do +-- start <- systemNanoseconds <$> getSystemTime +-- result <- m +-- end <- systemNanoseconds <$> getSystemTime +-- Debug.traceM $ msg ++ ": " ++ show (end - start) +-- pure result + initializeContext :: IO DrawContext initializeContext = do -- Initialize SDL - SDL.initializeAll + SDL.initialize [SDL.InitVideo, SDL.InitEvents] TTF.initialize window <- initializeWindow @@ -60,6 +70,4 @@ initializeWindow = do SDL.windowInitialSize = SDL.V2 0 0, SDL.windowBorder = False } - window <- SDL.createWindow "Chelleport" windowCfg - SDL.showWindow window - pure window + SDL.createWindow "Chelleport" windowCfg -- cgit v1.3.1