Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
8e93c048
Commit
8e93c048
authored
Dec 12, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bench for toPyhlo
parent
7ab4eb24
Pipeline
#5449
passed with stages
in 286 minutes and 38 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
30 deletions
+102
-30
issue-290.json
bench-data/phylo/issue-290.json
+1
-0
Main.hs
bench/Main.hs
+44
-8
gargantext.cabal
gargantext.cabal
+2
-0
Phylo.hs
src/Gargantext/Core/Types/Phylo.hs
+11
-2
Phylo.hs
src/Gargantext/Core/Viz/Phylo.hs
+34
-11
Tools.hs
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
+10
-9
No files found.
bench-data/phylo/issue-290.json
0 → 100644
View file @
8e93c048
This diff is collapsed.
Click to expand it.
bench/Main.hs
View file @
8e93c048
...
@@ -2,18 +2,54 @@
...
@@ -2,18 +2,54 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeApplications #-}
module
Main
where
module
Main
where
import
Control.DeepSeq
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Individu
import
Gargantext.Core.Types.Phylo
import
Gargantext.Core.Viz.Phylo
import
Gargantext.Core.Viz.Phylo.API.Tools
(
readPhylo
)
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
import
Gargantext.Prelude.Crypto.Auth
(
createPasswordHash
)
import
Gargantext.Prelude.Crypto.Auth
(
createPasswordHash
)
import
Test.Tasty.Bench
import
Test.Tasty.Bench
import
Paths_gargantext
phyloConfig
::
PhyloConfig
phyloConfig
=
PhyloConfig
{
corpusPath
=
"corpus.csv"
,
listPath
=
"list.csv"
,
outputPath
=
"data/"
,
corpusParser
=
Csv
{
_csv_limit
=
150000
}
,
listParser
=
V4
,
phyloName
=
"Phylo Name"
,
phyloScale
=
2
,
similarity
=
WeightedLogJaccard
{
_wlj_sensibility
=
0.5
,
_wlj_minSharedNgrams
=
2
}
,
seaElevation
=
Constante
{
_cons_start
=
0.1
,
_cons_gap
=
0.1
}
,
defaultMode
=
True
,
findAncestors
=
True
,
phyloSynchrony
=
ByProximityThreshold
{
_bpt_threshold
=
0.5
,
_bpt_sensibility
=
0.0
,
_bpt_scope
=
AllBranches
,
_bpt_strategy
=
MergeAllGroups
}
,
phyloQuality
=
Quality
{
_qua_granularity
=
0.8
,
_qua_minBranch
=
3
}
,
timeUnit
=
Year
{
_year_period
=
3
,
_year_step
=
1
,
_year_matchingFrame
=
5
}
,
clique
=
MaxClique
{
_mcl_size
=
5
,
_mcl_threshold
=
1.0e-4
,
_mcl_filter
=
ByThreshold
}
,
exportLabel
=
[
BranchLabel
{
_branch_labelTagger
=
MostEmergentTfIdf
,
_branch_labelSize
=
2
}
,
GroupLabel
{
_group_labelTagger
=
MostEmergentInclusive
,
_group_labelSize
=
2
}
]
,
exportSort
=
ByHierarchy
{
_sort_order
=
Desc
}
,
exportFilter
=
[
ByBranchSize
{
_branch_size
=
3.0
}]
}
main
::
IO
()
main
::
IO
()
main
=
defaultMain
main
=
do
[
bgroup
"Benchmarks"
issue290Phylo
<-
force
.
setConfig
phyloConfig
<$>
(
readPhylo
=<<
getDataFileName
"bench-data/phylo/issue-290.json"
)
[
bgroup
"User creation"
[
defaultMain
bench
"createPasswordHash"
$
whnfIO
(
createPasswordHash
"rabbit"
)
[
bgroup
"Benchmarks"
,
bench
"toUserHash"
$
[
bgroup
"User creation"
[
whnfIO
(
toUserHash
$
NewUser
"alfredo"
"alfredo@well-typed.com"
(
GargPassword
"rabbit"
))
bench
"createPasswordHash"
$
whnfIO
(
createPasswordHash
"rabbit"
)
]
,
bench
"toUserHash"
$
whnfIO
(
toUserHash
$
NewUser
"alfredo"
"alfredo@well-typed.com"
(
GargPassword
"rabbit"
))
]
,
bgroup
"Phylo"
[
bench
"toPhylo"
$
nf
toPhylo
issue290Phylo
]
]
]
]
]
gargantext.cabal
View file @
8e93c048
...
@@ -17,6 +17,7 @@ license: AGPL-3
...
@@ -17,6 +17,7 @@ license: AGPL-3
license-file: LICENSE
license-file: LICENSE
build-type: Simple
build-type: Simple
data-files:
data-files:
bench-data/phylo/issue-290.json
devops/postgres/extensions.sql
devops/postgres/extensions.sql
devops/postgres/schema.sql
devops/postgres/schema.sql
ekg-assets/index.html
ekg-assets/index.html
...
@@ -1157,6 +1158,7 @@ benchmark garg-bench
...
@@ -1157,6 +1158,7 @@ benchmark garg-bench
type: exitcode-stdio-1.0
type: exitcode-stdio-1.0
build-depends: base
build-depends: base
, bytestring
, bytestring
, deepseq
, gargantext
, gargantext
, gargantext-prelude
, gargantext-prelude
, tasty-bench
, tasty-bench
...
...
src/Gargantext/Core/Types/Phylo.hs
View file @
8e93c048
...
@@ -26,6 +26,7 @@ Phylomemy was first described in Chavalarias, D., Cointet, J.-P., 2013. Phylomem
...
@@ -26,6 +26,7 @@ Phylomemy was first described in Chavalarias, D., Cointet, J.-P., 2013. Phylomem
module
Gargantext.Core.Types.Phylo
where
module
Gargantext.Core.Types.Phylo
where
import
Control.DeepSeq
import
Control.Lens
(
makeLenses
)
import
Control.Lens
(
makeLenses
)
import
Control.Monad.Fail
(
fail
)
import
Control.Monad.Fail
(
fail
)
import
Data.Aeson
import
Data.Aeson
...
@@ -51,6 +52,8 @@ data Phylo = Phylo { _phylo_Duration :: (Start, End)
...
@@ -51,6 +52,8 @@ data Phylo = Phylo { _phylo_Duration :: (Start, End)
,
_phylo_Periods
::
[
PhyloPeriod
]
,
_phylo_Periods
::
[
PhyloPeriod
]
}
deriving
(
Generic
)
}
deriving
(
Generic
)
instance
NFData
Phylo
-- | UTCTime in seconds since UNIX epoch
-- | UTCTime in seconds since UNIX epoch
type
Start
=
POSIXTime
type
Start
=
POSIXTime
type
End
=
POSIXTime
type
End
=
POSIXTime
...
@@ -66,6 +69,8 @@ data PhyloPeriod = PhyloPeriod { _phylo_PeriodId :: PhyloPeriodId
...
@@ -66,6 +69,8 @@ data PhyloPeriod = PhyloPeriod { _phylo_PeriodId :: PhyloPeriodId
,
_phylo_PeriodLevels
::
[
PhyloLevel
]
,
_phylo_PeriodLevels
::
[
PhyloLevel
]
}
deriving
(
Generic
)
}
deriving
(
Generic
)
instance
NFData
PhyloPeriod
type
PhyloPeriodId
=
(
Start
,
End
)
type
PhyloPeriodId
=
(
Start
,
End
)
-- | PhyloLevel : levels of phylomemy on level axis
-- | PhyloLevel : levels of phylomemy on level axis
...
@@ -78,6 +83,8 @@ data PhyloLevel = PhyloLevel { _phylo_LevelId :: PhyloLevelId
...
@@ -78,6 +83,8 @@ data PhyloLevel = PhyloLevel { _phylo_LevelId :: PhyloLevelId
,
_phylo_LevelGroups
::
[
PhyloGroup
]
,
_phylo_LevelGroups
::
[
PhyloGroup
]
}
deriving
(
Generic
)
}
deriving
(
Generic
)
instance
NFData
PhyloLevel
type
PhyloLevelId
=
(
PhyloPeriodId
,
Int
)
type
PhyloLevelId
=
(
PhyloPeriodId
,
Int
)
-- | PhyloGroup : group of ngrams at each level and step
-- | PhyloGroup : group of ngrams at each level and step
...
@@ -88,14 +95,16 @@ type PhyloLevelId = (PhyloPeriodId, Int)
...
@@ -88,14 +95,16 @@ type PhyloLevelId = (PhyloPeriodId, Int)
data
PhyloGroup
=
PhyloGroup
{
_phylo_GroupId
::
PhyloGroupId
data
PhyloGroup
=
PhyloGroup
{
_phylo_GroupId
::
PhyloGroupId
,
_phylo_GroupLabel
::
Maybe
Text
,
_phylo_GroupLabel
::
Maybe
Text
,
_phylo_GroupNgrams
::
[
NgramId
]
,
_phylo_GroupNgrams
::
[
NgramId
]
,
_phylo_GroupPeriodParents
::
[
Edge
]
,
_phylo_GroupPeriodParents
::
[
Edge
]
,
_phylo_GroupPeriodChilds
::
[
Edge
]
,
_phylo_GroupPeriodChilds
::
[
Edge
]
,
_phylo_GroupLevelParents
::
[
Edge
]
,
_phylo_GroupLevelParents
::
[
Edge
]
,
_phylo_GroupLevelChilds
::
[
Edge
]
,
_phylo_GroupLevelChilds
::
[
Edge
]
}
deriving
(
Generic
)
}
deriving
(
Generic
)
instance
NFData
PhyloGroup
type
PhyloGroupId
=
(
PhyloLevelId
,
Int
)
type
PhyloGroupId
=
(
PhyloLevelId
,
Int
)
type
Edge
=
(
PhyloGroupId
,
Weight
)
type
Edge
=
(
PhyloGroupId
,
Weight
)
type
Weight
=
Double
type
Weight
=
Double
...
...
src/Gargantext/Core/Viz/Phylo.hs
View file @
8e93c048
...
@@ -26,6 +26,7 @@ one 8, e54847.
...
@@ -26,6 +26,7 @@ one 8, e54847.
module
Gargantext.Core.Viz.Phylo
where
module
Gargantext.Core.Viz.Phylo
where
import
Control.DeepSeq
import
Control.Lens
(
makeLenses
)
import
Control.Lens
(
makeLenses
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
...
@@ -62,7 +63,7 @@ data SeaElevation =
...
@@ -62,7 +63,7 @@ data SeaElevation =
|
Adaptative
|
Adaptative
{
_adap_steps
::
Double
}
{
_adap_steps
::
Double
}
|
Evolving
|
Evolving
{
_evol_neighborhood
::
Bool
}
{
_evol_neighborhood
::
Bool
}
deriving
(
Show
,
Generic
,
Eq
)
deriving
(
Show
,
Generic
,
Eq
)
instance
ToSchema
SeaElevation
instance
ToSchema
SeaElevation
...
@@ -74,8 +75,8 @@ data PhyloSimilarity =
...
@@ -74,8 +75,8 @@ data PhyloSimilarity =
|
WeightedLogSim
|
WeightedLogSim
{
_wls_sensibility
::
Double
{
_wls_sensibility
::
Double
,
_wls_minSharedNgrams
::
Int
}
,
_wls_minSharedNgrams
::
Int
}
|
Hamming
|
Hamming
{
_hmg_sensibility
::
Double
{
_hmg_sensibility
::
Double
,
_hmg_minSharedNgrams
::
Int
}
,
_hmg_minSharedNgrams
::
Int
}
deriving
(
Show
,
Generic
,
Eq
)
deriving
(
Show
,
Generic
,
Eq
)
...
@@ -188,7 +189,6 @@ data PhyloConfig =
...
@@ -188,7 +189,6 @@ data PhyloConfig =
,
exportFilter
::
[
Filter
]
,
exportFilter
::
[
Filter
]
}
deriving
(
Show
,
Generic
,
Eq
)
}
deriving
(
Show
,
Generic
,
Eq
)
--------------------------------
--------------------------------
-- | SubConfig API & 1Click | --
-- | SubConfig API & 1Click | --
--------------------------------
--------------------------------
...
@@ -205,8 +205,8 @@ data PhyloSubConfigAPI =
...
@@ -205,8 +205,8 @@ data PhyloSubConfigAPI =
subConfigAPI2config
::
PhyloSubConfigAPI
->
PhyloConfig
subConfigAPI2config
::
PhyloSubConfigAPI
->
PhyloConfig
subConfigAPI2config
subConfig
=
defaultConfig
subConfigAPI2config
subConfig
=
defaultConfig
{
similarity
=
WeightedLogJaccard
(
_sc_phyloProximity
subConfig
)
2
{
similarity
=
WeightedLogJaccard
(
_sc_phyloProximity
subConfig
)
2
,
phyloSynchrony
=
ByProximityThreshold
(
_sc_phyloSynchrony
subConfig
)
0
AllBranches
MergeAllGroups
,
phyloSynchrony
=
ByProximityThreshold
(
_sc_phyloSynchrony
subConfig
)
0
AllBranches
MergeAllGroups
,
phyloQuality
=
Quality
(
_sc_phyloQuality
subConfig
)
3
,
phyloQuality
=
Quality
(
_sc_phyloQuality
subConfig
)
3
,
timeUnit
=
_sc_timeUnit
subConfig
,
timeUnit
=
_sc_timeUnit
subConfig
...
@@ -217,7 +217,7 @@ subConfigAPI2config subConfig = defaultConfig
...
@@ -217,7 +217,7 @@ subConfigAPI2config subConfig = defaultConfig
--------------------------
--------------------------
-- | SubConfig 1Click | --
-- | SubConfig 1Click | --
--------------------------
--------------------------
defaultConfig
::
PhyloConfig
defaultConfig
::
PhyloConfig
defaultConfig
=
defaultConfig
=
...
@@ -474,7 +474,6 @@ data PhyloScale =
...
@@ -474,7 +474,6 @@ data PhyloScale =
instance
ToSchema
PhyloScale
where
instance
ToSchema
PhyloScale
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_phylo_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_phylo_"
)
type
PhyloGroupId
=
(
PhyloScaleId
,
Int
)
type
PhyloGroupId
=
(
PhyloScaleId
,
Int
)
-- | BranchId : (a scale, a sequence of branch index)
-- | BranchId : (a scale, a sequence of branch index)
...
@@ -552,19 +551,16 @@ data Filter = ByBranchSize { _branch_size :: Double } deriving (Show,Generic,Eq)
...
@@ -552,19 +551,16 @@ data Filter = ByBranchSize { _branch_size :: Double } deriving (Show,Generic,Eq)
instance
ToSchema
Filter
where
instance
ToSchema
Filter
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
""
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
""
)
data
Order
=
Asc
|
Desc
deriving
(
Show
,
Generic
,
Eq
,
ToSchema
)
data
Order
=
Asc
|
Desc
deriving
(
Show
,
Generic
,
Eq
,
ToSchema
)
data
Sort
=
ByBirthDate
{
_sort_order
::
Order
}
|
ByHierarchy
{
_sort_order
::
Order
}
deriving
(
Show
,
Generic
,
Eq
)
data
Sort
=
ByBirthDate
{
_sort_order
::
Order
}
|
ByHierarchy
{
_sort_order
::
Order
}
deriving
(
Show
,
Generic
,
Eq
)
instance
ToSchema
Sort
where
instance
ToSchema
Sort
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_sort_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_sort_"
)
data
Tagger
=
MostInclusive
|
MostEmergentInclusive
|
MostEmergentTfIdf
deriving
(
Show
,
Generic
,
Eq
)
data
Tagger
=
MostInclusive
|
MostEmergentInclusive
|
MostEmergentTfIdf
deriving
(
Show
,
Generic
,
Eq
)
instance
ToSchema
Tagger
where
instance
ToSchema
Tagger
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
""
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
""
)
data
PhyloLabel
=
data
PhyloLabel
=
BranchLabel
BranchLabel
{
_branch_labelTagger
::
Tagger
{
_branch_labelTagger
::
Tagger
...
@@ -654,3 +650,30 @@ instance FromJSON PhyloGroup
...
@@ -654,3 +650,30 @@ instance FromJSON PhyloGroup
instance
ToJSON
PhyloGroup
instance
ToJSON
PhyloGroup
$
(
deriveJSON
(
unPrefix
"_foundations_"
)
''
P
hyloFoundations
)
$
(
deriveJSON
(
unPrefix
"_foundations_"
)
''
P
hyloFoundations
)
-- NFData instances
instance
NFData
CorpusParser
instance
NFData
ListParser
instance
NFData
SeaElevation
instance
NFData
PhyloSimilarity
instance
NFData
SynchronyScope
instance
NFData
SynchronyStrategy
instance
NFData
Synchrony
instance
NFData
MaxCliqueFilter
instance
NFData
Cluster
instance
NFData
Quality
instance
NFData
PhyloConfig
instance
NFData
Software
instance
NFData
PhyloParam
instance
NFData
PhyloFoundations
instance
NFData
PhyloCounts
instance
NFData
PhyloSources
instance
NFData
Phylo
instance
NFData
PhyloPeriod
instance
NFData
PhyloScale
instance
NFData
Filter
instance
NFData
Order
instance
NFData
Sort
instance
NFData
Tagger
instance
NFData
PhyloLabel
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
View file @
8e93c048
...
@@ -19,7 +19,7 @@ module Gargantext.Core.Viz.Phylo.API.Tools
...
@@ -19,7 +19,7 @@ module Gargantext.Core.Viz.Phylo.API.Tools
where
where
import
Control.Lens
hiding
(
Context
)
import
Control.Lens
hiding
(
Context
)
import
Data.Aeson
(
Value
,
decodeFileStrict
,
e
itherDecode
,
encode
)
import
Data.Aeson
(
Value
,
decodeFileStrict
,
e
ncode
,
eitherDecodeFileStrict'
)
import
Data.ByteString.Lazy
qualified
as
Lazy
import
Data.ByteString.Lazy
qualified
as
Lazy
import
Data.Map.Strict
qualified
as
Map
import
Data.Map.Strict
qualified
as
Map
import
Data.Proxy
import
Data.Proxy
...
@@ -54,6 +54,7 @@ import Prelude qualified
...
@@ -54,6 +54,7 @@ import Prelude qualified
import
System.FilePath
((
</>
))
import
System.FilePath
((
</>
))
import
System.IO.Temp
(
withTempDirectory
)
import
System.IO.Temp
(
withTempDirectory
)
import
System.Process
qualified
as
Shell
import
System.Process
qualified
as
Shell
import
Gargantext.Utils.UTCTime
(
timeMeasured
)
--------------------------------------------------------------------
--------------------------------------------------------------------
getPhyloData
::
HasNodeError
err
getPhyloData
::
HasNodeError
err
...
@@ -99,7 +100,12 @@ flowPhyloAPI config cId = do
...
@@ -99,7 +100,12 @@ flowPhyloAPI config cId = do
-- writePhylo phyloWithCliquesFile phyloWithCliques
-- writePhylo phyloWithCliquesFile phyloWithCliques
$
(
logLocM
)
DEBUG
$
"PhyloConfig old: "
<>
show
config
$
(
logLocM
)
DEBUG
$
"PhyloConfig old: "
<>
show
config
pure
$!
toPhylo
$!
setConfig
config
phyloWithCliques
_
<-
timeMeasured
"flowPhyloAPI.phyloWithCliques"
(
pure
$!
phyloWithCliques
)
let
!
phyloConfigured
=
setConfig
config
phyloWithCliques
_
<-
timeMeasured
"flowPhyloAPI.phyloConfigured"
(
pure
$!
phyloConfigured
)
pure
$!
toPhylo
phyloConfigured
--------------------------------------------------------------------
--------------------------------------------------------------------
corpusIdtoDocuments
::
(
HasNodeStory
env
err
m
,
HasNodeError
err
)
corpusIdtoDocuments
::
(
HasNodeStory
env
err
m
,
HasNodeError
err
)
...
@@ -195,13 +201,8 @@ writePhylo path phylo = Lazy.writeFile path $ encode phylo
...
@@ -195,13 +201,8 @@ writePhylo path phylo = Lazy.writeFile path $ encode phylo
readPhylo
::
[
Char
]
->
IO
Phylo
readPhylo
::
[
Char
]
->
IO
Phylo
readPhylo
path
=
do
readPhylo
path
=
do
phyloJson
<-
(
eitherDecode
<$>
readJson
path
)
::
IO
(
Either
Prelude
.
String
Phylo
)
phyloJson
<-
eitherDecodeFileStrict'
@
Phylo
path
case
phyloJson
of
either
errorTrace
pure
phyloJson
Left
err
->
do
putStrLn
err
undefined
Right
phylo
->
pure
phylo
-- | To read and decode a Json file
-- | To read and decode a Json file
readJson
::
FilePath
->
IO
Lazy
.
ByteString
readJson
::
FilePath
->
IO
Lazy
.
ByteString
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment