0

I want to try using some reporters in my benchmark for function Main.lengthOfUUID.


object Main {

  def lengthOfUUID(s : Int) = {
    val x = List.fill(100000)(1)
    val sum = x.sum
  }
}

Firstly I tried ChartReporter

import org.scalameter.api._
import org.scalameter.picklers.Implicits._

object UUIDBench extends Bench[Double] {


  lazy val executor = LocalExecutor(
    new Executor.Warmer.Default,
    Aggregator.min[Double],
    measurer)
  lazy val measurer = new Measurer.Default
  lazy val reporter = ChartReporter(ChartFactory.XYLine())
  lazy val persistor = Persistor.None
  val sizes: Gen[Int] = Gen.range("size")(1, 8, 1)
  val ranges: Gen[Range] = for {
    size <- sizes
  } yield 0 until size
  performance of "Batches" config (
    exec.benchRuns -> 4
    ) in {
    measure method "main" in {
      using(sizes) in { s =>
        Main.lengthOfUUID(s)
      }
    }
  }
}

But it throws a error

Error:(14, 36) ambiguous implicit values:
 both object BigIntIsIntegral in object Numeric of type scala.math.Numeric.BigIntIsIntegral.type
 and object IntIsIntegral in object Numeric of type scala.math.Numeric.IntIsIntegral.type
 match expected type Numeric[T]
Error occurred in an application involving default arguments.
  lazy val reporter = ChartReporter(ChartFactory.XYLine())
Error:(14, 36) could not find implicit value for evidence parameter of type Numeric[T]
Error occurred in an application involving default arguments.
  lazy val reporter = ChartReporter(ChartFactory.XYLine())
Error:(14, 36) not enough arguments for method apply: (implicit evidence$1: Numeric[T])org.scalameter.reporting.ChartReporter[T] in object ChartReporter.
Unspecified value parameter evidence$1.
Error occurred in an application involving default arguments.
  lazy val reporter = ChartReporter(ChartFactory.XYLine())

I saw this issue. Code there is not available now, but it is said to use HTMLReporter, so I tried it

lazy val reporter = Reporter.Composite(
    new RegressionReporter(
      RegressionReporter.Tester.OverlapIntervals(),
      RegressionReporter.Historian.ExponentialBackoff() ),
    HtmlReporter(true)
  )

But got similar errors

Error:(15, 5) ambiguous implicit values:
 both object BigIntIsIntegral in object Numeric of type scala.math.Numeric.BigIntIsIntegral.type
 and object IntIsIntegral in object Numeric of type scala.math.Numeric.IntIsIntegral.type
 match expected type Numeric[T]
    new RegressionReporter(
Error:(15, 5) could not find implicit value for evidence parameter of type Numeric[T]
    new RegressionReporter(
Error:(15, 5) not enough arguments for constructor RegressionReporter: (implicit evidence$1: Numeric[T])org.scalameter.reporting.RegressionReporter[T].
Unspecified value parameter evidence$1.
    new RegressionReporter(
Error:(18, 17) ambiguous implicit values:
 both object BigIntIsIntegral in object Numeric of type scala.math.Numeric.BigIntIsIntegral.type
 and object IntIsIntegral in object Numeric of type scala.math.Numeric.IntIsIntegral.type
 match expected type Numeric[T]
    HtmlReporter(true)
Error:(18, 17) could not find implicit value for evidence parameter of type Numeric[T]
    HtmlReporter(true)
Error:(18, 17) not enough arguments for method apply: (implicit evidence$1: Numeric[T])org.scalameter.reporting.HtmlReporter[T] in object HtmlReporter.
Unspecified value parameter evidence$1.
    HtmlReporter(true)

How should I use these reporters?

Nourless
  • 729
  • 1
  • 5
  • 18
  • I copied your code and run it with no issues. What's `do_job.main`? Why do you even pass `null`? That is not very idiomatic Scala. – mfirry Jan 13 '21 at 08:26
  • that's some placeholder for object I need to benchmark. `null` is passed because `main` function takes args `Array` as parameters. – Nourless Jan 13 '21 at 08:50
  • `Array.empty` is better than. Regardless as I said I copied your code and compile it with no issues. Would you mind updating the question with your current code? It says error at line 15... for which file? what line? – mfirry Jan 13 '21 at 09:26
  • @mfirry I added code for example. – Nourless Jan 13 '21 at 11:03
  • You said you're not using `ChartReporter`... would you mind putting the code you're actually running now? It's very confusing. – mfirry Jan 13 '21 at 11:30
  • @mfirry Where did I said that I am not using it? I wanted to use it and post the errors which I got during this. After this I tried `HTMLReporter` and got similar errors. All of this I posted above. Actually running is only `LoggingReporter` because `Chart` and `HTML` don't work. Sorry if some misunderstanding happened – Nourless Jan 13 '21 at 12:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/227279/discussion-between-mfirry-and-nourless). – mfirry Jan 13 '21 at 13:02

0 Answers0