Open fsarradin opened 6 years ago
It doesn't work with Magnolia for the following case class :
case class SimpleCaseClass(field: String)
case class WithOption(field:String,opt:Option[String],opt2:Option[SimpleCaseClass])
=> Updating Shapeless !
Time to add JMH (Java Microbenchmark Harness). 4 benchmarks to do:
Result of the bench
[info] # Run complete. Total time: 00:25:07
[info] Benchmark Mode Cnt Score Error Units
[info] ToMapBench.toMap_byHand_baseline thrpt 25 393064.803 ± 2652.298 ops/s
[info] ToMapBench.toMap_javaReflection thrpt 25 631668.980 ± 5091.875 ops/s
[info] ToMapBench.toMap_shapeless thrpt 25 2362843.487 ± 174641.869 ops/s
Note: I've some problems with the Magnolia version due to implicit resolution
ToMapBench.scala:41:10: could not find implicit value for evidence parameter of type sandbox.ToMap[zoom.bench.sandbox.Level1CC]
Updated bench
[info] Benchmark Mode Cnt Score Error Units
[info] ToMapBench.toMap_byHand_baseline thrpt 25 5780259.775 ± 40263.865 ops/s
[info] ToMapBench.toMap_javaReflection thrpt 25 890603.361 ± 13304.667 ops/s
[info] ToMapBench.toMap_shapeless thrpt 25 2362843.487 ± 174641.869 ops/s
Last results
[info] ToMapBench.toMap_byHand2 thrpt 25 218146598.332 ± 11540543.920 ops/s
[info] ToMapBench.toMap_byHand_baseline thrpt 25 5873689.543 ± 56151.495 ops/s
[info] ToMapBench.toMap_javaReflection thrpt 25 989298.519 ± 45815.272 ops/s
[info] ToMapBench.toMap_magniola thrpt 25 852163.410 ± 13319.356 ops/s
[info] ToMapBench.toMap_shapeless thrpt 25 3759700.042 ± 228861.262 ops/s
And with magnolia 2
[info] Benchmark Mode Cnt Score Error Units
[info] ToMapBench.toMap_byHand2 thrpt 25 220553937.130 ± 3735241.241 ops/s
[info] ToMapBench.toMap_byHand_baseline thrpt 25 5766268.744 ± 44173.483 ops/s
[info] ToMapBench.toMap_shapeless thrpt 25 3583706.298 ± 76165.337 ops/s
[info] ToMapBench.toMap_Magniola2 thrpt 25 1272567.203 ± 40474.024 ops/s
[info] ToMapBench.toMap_javaReflection thrpt 25 972149.288 ± 34727.019 ops/s
[info] ToMapBench.toMap_magniola thrpt 25 816225.914 ± 12217.223 ops/s
Final strategy:
Map[String, String]
getCCParams2
is currently using runtime reflection in order to convert case class intoMap[String, String]
.There should be a better, using Shapeless or Magnolia, in a view to make its analysis at compile-time.