Skip to content

doobie-example with an experiment for learning purposes

Notifications You must be signed in to change notification settings

ZDevelop94/doobie-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Was confirming if IO.parTraverseN(3)(staff)(member => repo.insertData(member._1, member._2, member._3).transact(xa)).void is faster than

val staffIOs = staff.map(repo.insertData).map(_.transact(xa))
staffIOs.parSequenceN(3)

hypothesis:

The first code example is faster because the cats library has an optimised algorithm that analyses the Functor at the same time as the current position of the collection where as .map .map has to loop through and munipulate the collection 3 times including the parSequence

Result:

result is that the code using parTraverseN (first code example) was faster as I created a recursive function that repeated the side effect with x amount of elements (look at code). This then gave me the average time taken (with reliable results) without running the program multiple times; as this brings into the factor cpu thread alocation, spinup time and other process running on my machine between intevals of program execution.

There is only several milisecond difference but this is crucial when intense systems dealing with millions of datapoints have to use the best solution to reduce latency.

Run it yourself if you wish just don't forget to uncomment and comment out the different sections of code.

About

doobie-example with an experiment for learning purposes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages