Skip to content

Loading…

Path creation now relies on efficient Elem hashing #58

Merged
merged 3 commits into from

2 participants

@ncreep

Getting the following performance:

[info] Heap: 1820MB
[info] Java: Sun Microsystems Inc. 1.6.0_25
[info] OS: Windows 7 6.1 amd64
[info]
[info] -- Memory Usage (7 MB) --
[info] anti-xml: 56605672
[info] scala.xml: 26514864
[info] javax.xml: 49023256
[info]
[info] -- Execution Time --
[info] Loading a 7 MB XML file
[info] + anti-xml: min: 435 ms, max: 453 ms, average: 440 ms
[info] + anti-xml StAX: min: 407 ms, max: 434 ms, average: 418 ms
[info] + scala.xml: min: 157 ms, max: 164 ms, average: 158 ms
[info] + javax.xml: min: 114 ms, max: 125 ms, average: 115 ms
[info] Shallow selection in a 7 MB tree
[info] + anti-xml: min: 57 ms, max: 66 ms, average: 59 ms
[info] + scala.xml: min: 25 ms, max: 27 ms, average: 25 ms
[info] Deep selection in a 7 MB tree
[info] + anti-xml: min: 581 ms, max: 651 ms, average: 600 ms
[info] + scala.xml: min: 449 ms, max: 478 ms, average: 459 ms
[info] + javax.xml: min: 14 ms, max: 16 ms, average: 14 ms

@djspiewak djspiewak merged commit e735f2b into djspiewak:zipper-replacement
@djspiewak
Owner

Merged! My numbers are not quite as good, but still quite respectable:

[info] Heap: 2039MB
[info] Java: Apple Inc. 1.6.0_26
[info] OS: Mac OS X 10.7.1 x86_64
[info] 
[info] -- Memory Usage (7 MB) --
[info] anti-xml:  56605672
[info] scala.xml: 26514864
[info] javax.xml: 49023256
[info] 
[info] -- Execution Time --
[info] Loading a 7 MB XML file
[info]  + anti-xml: min: 485 ms, max: 499 ms, average: 489 ms
[info]  + anti-xml StAX: min: 483 ms, max: 503 ms, average: 491 ms
[info]  + scala.xml: min: 230 ms, max: 234 ms, average: 231 ms
[info]  + javax.xml: min: 129 ms, max: 152 ms, average: 131 ms
[info] Shallow selection in a 7 MB tree
[info]  + anti-xml: min: 63 ms, max: 65 ms, average: 63 ms
[info]  + scala.xml: min: 17 ms, max: 18 ms, average: 17 ms
[info] Deep selection in a 7 MB tree
[info]  + anti-xml: min: 661 ms, max: 686 ms, average: 668 ms
[info]  + scala.xml: min: 399 ms, max: 408 ms, average: 403 ms
[info]  + javax.xml: min: 15 ms, max: 20 ms, average: 17 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 24, 2011
  1. @ncreep

    Doc fix.

    ncreep committed
Commits on Sep 26, 2011
  1. @ncreep

    Merge branch 'zipper-replacement' of git://github.com/djspiewak/anti-…

    ncreep committed
    …xml into zipper-replacement
  2. @ncreep

    Path creation relies on efficient hashing of Elems.

    ncreep committed
    Added a comment about hashing in PathCreator and DeepZipper.
This page is out of date. Refresh to see the latest.
View
1 src/main/scala/com/codecommit/antixml/DeepZipper.scala
@@ -300,6 +300,7 @@ trait DeepZipper[+A <: Node] extends Group[A] with IndexedSeqLike[A, DeepZipper[
* of contexts at depth -1 from the original.
*/
private def mergeDepth(singleDepthContexts: Seq[FullContext], singleDepthTransforms: Map[FullLoc, NodeTransform]) = {
+ // the following can only be used if [[Elem]] has efficient hashing
val contexts = singleDepthContexts.groupBy(_.parentsList) withDefaultValue Seq()
val transforms = singleDepthTransforms.groupBy(_._1.parentsList) withDefaultValue Map()
View
9 src/main/scala/com/codecommit/antixml/PathCreator.scala
@@ -116,14 +116,9 @@ private[antixml] object PathCreator {
/** The location contexts and the corresponding contents. */
val (locs, contents) = contexts.unzip
- require(removeParents(locs).toSet.size == locs.size, "Cannot have duplicate locations in path") // enforcing no duplicates policy
+ // this can only be used if [[Elem]] has efficient hashing
+ require((locs).toSet.size == locs.size, "Cannot have duplicate locations in path") // enforcing no duplicates policy
- /** A wrapper for location which omits [[Elem]] data from the parents list.
- * Hashing on this is faster than of on [[LocationContext]]. */
- private case class LocContextNoParents(loc: Location, parents: Seq[Location])
- private def removeParents(locs: Seq[LocationContext]) = {
- locs map (l => LocContextNoParents(l.loc, l.parentsList.map(_.loc)))
- }
}
}
Something went wrong with that request. Please try again.