Prepare to V2 - #196
Draft
willbasky wants to merge 12 commits into
Draft
Conversation
added 9 commits
July 19, 2024 18:53
willbasky
marked this pull request as ready for review
August 7, 2024 17:31
willbasky
marked this pull request as draft
September 22, 2024 19:57
willbasky
marked this pull request as ready for review
September 23, 2024 02:04
willbasky
marked this pull request as draft
September 23, 2024 02:12
Collaborator
Author
|
Due to benchmarks of module Main (main) where
import Criterion
import Criterion.Main (defaultMain)
import Data.List (nubBy, unionBy)
import Hedgehog (MonadGen)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import NubAndUnion (nubWith, unionWith)
main :: IO ()
main = nubBenchmark
nubBenchmark :: IO ()
nubBenchmark =
defaultMain
[ bgroup "nub" [
env (Gen.sample (genListOfInt 10000 1000)) $ \input ->
bgroup
"10000"
[ bench "nubBy" $ nf (nubBy (/=)) input
, bench "nubWith" $ nf (nubWith id) input
]
]
, bgroup "union" [
env (Gen.sample (genListOfInt2 10000 1000)) $ \x ->
bgroup
"10000"
[ bench "unionBy" $ nf (uncurry (unionBy (/=))) x
, bench "unionWith" $ nf (uncurry (unionWith id)) x
]
]
]
genListOfInt :: (MonadGen m) => Int -> Int -> m [Int]
genListOfInt l i = Gen.list (Range.singleton l) $ Gen.int (Range.constant 0 i)
genListOfInt2 :: (MonadGen m) => Int -> Int -> m ([Int], [Int])
genListOfInt2 l i = do
l1 <- Gen.list (Range.singleton l) $ Gen.int (Range.constant 0 (i+i))
l2 <- Gen.list (Range.singleton l) $ Gen.int (Range.constant 0 i)
pure (l1,l2)
it returns: |
Collaborator
Author
|
See solution here https://github.com/nh2/haskell-ordnub |
Collaborator
Author
|
Well, my solution is the same by performance as haskell-ordnub. So, I guess Ord adds extra time. One has to research it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.