-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from gnieh/performances/jsonpatch-diff
Improve JsonPatch diff performances
- Loading branch information
Showing
11 changed files
with
164 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version = "3.7.2" | ||
version = "3.7.1" | ||
maxColumn = 120 | ||
danglingParentheses.preset = false | ||
align.preset = some | ||
|
58 changes: 58 additions & 0 deletions
58
benchmarks/src/main/scala/diffson/PatienceBenchmarks.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package diffson | ||
|
||
import org.openjdk.jmh.annotations.State | ||
import org.openjdk.jmh.annotations.Scope | ||
import org.openjdk.jmh.annotations.BenchmarkMode | ||
import org.openjdk.jmh.annotations.Mode | ||
import org.openjdk.jmh.annotations.Fork | ||
import org.openjdk.jmh.annotations.Warmup | ||
import org.openjdk.jmh.annotations.Measurement | ||
|
||
import diffson.circe._ | ||
import diffson.jsonpatch.lcsdiff._ | ||
import diffson.lcs._ | ||
|
||
import io.circe.syntax._ | ||
import io.circe.Json | ||
import org.openjdk.jmh.annotations.Benchmark | ||
|
||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@State(Scope.Benchmark) | ||
@Fork(value = 1) | ||
@Warmup(iterations = 3, time = 2) | ||
@Measurement(iterations = 5, time = 2) | ||
class PatienceBenchmarks { | ||
|
||
implicit val lcs = new Patience[Json] | ||
|
||
private def createJson(depth: Int, arrayStep: Int) = | ||
List | ||
.range(depth, 0, -1) | ||
.foldLeft(Json.obj("array" := List.range(0, 1000, arrayStep).map(n => Json.obj("n" := n, "other" := "common")))) { | ||
(acc, idx) => | ||
Json.obj(s"key$idx" := acc, "other" := arrayStep) | ||
} | ||
|
||
def array(size: Int, step: Int) = | ||
Json.obj("array" := List.range(0, size, step)) | ||
|
||
val deep1 = | ||
createJson(100, 1) | ||
|
||
val deep2 = | ||
createJson(100, 2) | ||
|
||
val array1 = | ||
array(1000, 2) | ||
|
||
val array2 = | ||
array(1000, 1) | ||
|
||
@Benchmark | ||
def diffArray() = | ||
diff(array1, array2) | ||
|
||
@Benchmark | ||
def diffDeep() = | ||
diff(deep1, deep2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.