Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compilation of the benchmark. #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions benchmark/Benchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ main = do
liftIO $ putMVar done ()

let timeAction name nActions action = do
startT <- getCurrentTime
-- each clients runs ACTION nRepetitions times
let nRepetitions = nRequests `div` nClients `div` nActions
replicateM_ nClients $ putMVar start (replicateM_ nRepetitions action)
replicateM_ nClients $ takeMVar done
stopT <- getCurrentTime
let deltaT = realToFrac $ diffUTCTime stopT startT
-- the real # of reqs send. We might have lost some due to 'div'.
actualReqs = nRepetitions * nActions * nClients
rqsPerSec = fromIntegral actualReqs / deltaT :: Double
putStrLn $ printf "%-20s %10.2f Req/s" (name :: String) rqsPerSec
startT <- getCurrentTime
-- each clients runs ACTION nRepetitions times
let nRepetitions = nRequests `div` nClients `div` nActions
replicateM_ nClients $ putMVar start (replicateM_ nRepetitions action)
replicateM_ nClients $ takeMVar done
stopT <- getCurrentTime
let deltaT = realToFrac $ diffUTCTime stopT startT
-- the real # of reqs send. We might have lost some due to 'div'.
actualReqs = nRepetitions * nActions * nClients
rqsPerSec = fromIntegral actualReqs / deltaT :: Double
putStrLn $ printf "%-20s %10.2f Req/s" (name :: String) rqsPerSec

----------------------------------------------------------------------
-- Benchmarks
Expand Down
1 change: 0 additions & 1 deletion src/Database/Redis/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ XReadOpts(..),
defaultXreadOpts,
XReadResponse(..),
StreamsRecord(..),
TrimOpts(..),
xadd,
xaddOpts,
XAddOpts(..),
Expand Down
1 change: 0 additions & 1 deletion src/Database/Redis/Sentinel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import Control.Exception (Exception, IOException, evaluate, throwI
import Control.Monad
import Control.Monad.Catch (Handler (..), MonadCatch, catches, throwM)
import Control.Monad.Except
import Control.Monad.IO.Class(MonadIO(liftIO))
Copy link
Contributor

@ysangkok ysangkok Jun 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is needed on mtl-2.3, because re-exports are removed. If this line was removed to avoid a warning, I think it would be better to just make all imports use explicit import lists, instead of open imports.

That way, the code will be easier to read, and compatible with both mtl-2.2 and mtl-2.3, and there will be no warning.

For more explanation of this line, see #190

Copy link
Collaborator

@qnikst qnikst Jun 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a trick with applicative and prelude after re-exports were added that

import Control.Applicative
import Prelude

worked without warnings.

Maybe we can write:

import Control.Monad.IO.Class(MonadIO(liftIO))
import Control.Monad.Except -- the import order changed in order to avoid warnings

It may not work well with code formatters, but it should fix a warning and does not require CPP.

import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
Expand Down