Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support performance measurement for solutions #2

Open
ihac opened this issue Jul 18, 2018 · 1 comment
Open

Support performance measurement for solutions #2

ihac opened this issue Jul 18, 2018 · 1 comment
Assignees

Comments

@ihac
Copy link
Owner

ihac commented Jul 18, 2018

Three concerns:

  1. compute complexity (in theory)
  2. average execution time
  3. average memory usage

It stills require a deeper research on which benchmark framework is best, and easy-to-use of course.

@ihac ihac self-assigned this Jul 18, 2018
@ihac
Copy link
Owner Author

ihac commented Jul 24, 2018

inline benchmarking provided by ScalaMeter (import scalameter for benchmarking) is quite convenient:

  test("compare performance by large test set") {
    val inputs = 10 to 100000 by 1000
    val raw_time = standardConfig measure {
      inputs.foreach(_.totient)
    }
    val improved_time = standardConfig measure {
      inputs.foreach(_.totient_improve)
    }

    println(s"totient: ${raw_time}, totient_improved: ${improved_time}")
    println(s"speedup: ${raw_time.value / improved_time.value}")
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant