Skip to content

MapValue#equals too slow #165

Open
Open

Description

@xuwei-k

version 0.7.0-p2

import org.msgpack.value._

object Main {

  def mapValueEqualsTime(size: Int): Unit = {
    val keyValues: Array[Value] = (1 to size).flatMap{ key =>
      Seq(ValueFactory.newString(key.toString), ValueFactory.nilValue())
    }.toArray
    val map1, map2 = ValueFactory.newMap(keyValues)
    println(size)
    System.gc
    val start = System.nanoTime
    map1 == map2
    println((System.nanoTime - start) / 1000000.0)
    println
  }

  def main(args: Array[String]) {
    mapValueEqualsTime(10)
    mapValueEqualsTime(100)
    mapValueEqualsTime(1000)
    mapValueEqualsTime(10000)
    mapValueEqualsTime(100000)
  }

}

result

10
1.634357

100
4.078424

1000
10.137222

10000
183.871329

100000
22959.867596

Activity

  1. added this to the 0.7.0-M6 milestone on Jan 16, 2015
  2. xerial commented on Jun 23, 2015

    @xerial
    Member

    New MapValue.equals is implemented by translating the value into a Map:
    https://github.com/msgpack/msgpack-java/blob/v07-develop/msgpack-core/src/main/java/org/msgpack/value/impl/ImmutableMapValueImpl.java#L137-137

    This implementation still might have this performance problem.

  3. modified the milestones: 0.7.0-M6, v08 on Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions