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

optimize com.trueaccord.scalapb.Encoding #56

Merged
merged 1 commit into from
Nov 17, 2015

Conversation

xuwei-k
Copy link
Contributor

@xuwei-k xuwei-k commented Nov 17, 2015

package com.trueaccord.scalapb

object Benchmark {
  def main(args: Array[String]): Unit = {
    val n = 5000
    val lists = Array.fill(n)(Array.fill(5000)(util.Random.nextInt.toByte))

    for(x <- 1 to 5){
      var i = 0
      val start = System.currentTimeMillis
      while(i < n) {
        Encoding.fromBase64(Encoding.toBase64(lists(i)))
        i += 1
      }
      println((System.currentTimeMillis - start) / 1000.0)
    }
  }
}

old

[info] Running com.trueaccord.scalapb.Benchmark 
7.129
5.963
5.866
5.905
5.824

new

[info] Running com.trueaccord.scalapb.Benchmark 
2.615
1.857
1.777
1.856
1.838

@thesamet
Copy link
Contributor

Nice!

thesamet added a commit that referenced this pull request Nov 17, 2015
optimize com.trueaccord.scalapb.Encoding
@thesamet thesamet merged commit ed48111 into scalapb:master Nov 17, 2015
@xuwei-k xuwei-k deleted the optimize-Encoding branch November 17, 2015 16:32
@xuwei-k xuwei-k mentioned this pull request Nov 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants