Skip to content

Commit

Permalink
Lazy Index Map (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored Sep 11, 2023
1 parent 3884403 commit e9a4341
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 37 deletions.
61 changes: 61 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ strum = { version = "0.25.0", features = ["derive"] }
strum_macros = "0.25.0"
num-bigint = "0.4.3"
num-traits = "0.2.16"
ahash = "0.8.0"
smallvec = "1.11.0"

[dev-dependencies]
paste = "1.0.7"
serde_json = {version = "1.0.87", features = ["preserve_order"]}
serde_json = {version = "1.0.87", features = ["preserve_order", "arbitrary_precision"]}
serde = "1.0.147"

[profile.bench]
Expand Down
3 changes: 3 additions & 0 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,6 @@ test_cases!(string_array);
test_cases!(true_array);
test_cases!(true_object);
test_cases!(bigints_array);
// from https://github.com/json-iterator/go-benchmark/blob/179abe5e3f72acce34fb5a16f3473b901fbdd6b9/
// src/github.com/json-iterator/go-benchmark/benchmark.go#L30C17-L30C29
test_cases!(medium_response);
93 changes: 93 additions & 0 deletions benches/medium_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"person": {
"id": "d50887ca-a6ce-4e59-b89f-14f0b5d03b03",
"name": {
"fullName": "Leonid Bugaev",
"givenName": "Leonid",
"familyName": "Bugaev"
},
"email": "[email protected]",
"gender": "male",
"location": "Saint Petersburg, Saint Petersburg, RU",
"geo": {
"city": "Saint Petersburg",
"state": "Saint Petersburg",
"country": "Russia",
"lat": 59.9342802,
"lng": 30.3350986
},
"bio": "Senior engineer at Granify.com",
"site": "http://flickfaver.com",
"avatar": "https://d1ts43dypk8bqh.cloudfront.net/v1/avatars/d50887ca-a6ce-4e59-b89f-14f0b5d03b03",
"employment": {
"name": "www.latera.ru",
"title": "Software Engineer",
"domain": "gmail.com"
},
"facebook": {
"handle": "leonid.bugaev"
},
"github": {
"handle": "buger",
"id": 14009,
"avatar": "https://avatars.githubusercontent.com/u/14009?v=3",
"company": "Granify",
"blog": "http://leonsbox.com",
"followers": 95,
"following": 10
},
"twitter": {
"handle": "flickfaver",
"id": 77004410,
"bio": null,
"followers": 2,
"following": 1,
"statuses": 5,
"favorites": 0,
"location": "",
"site": "http://flickfaver.com",
"avatar": null
},
"linkedin": {
"handle": "in/leonidbugaev"
},
"googleplus": {
"handle": null
},
"angellist": {
"handle": "leonid-bugaev",
"id": 61541,
"bio": "Senior engineer at Granify.com",
"blog": "http://buger.github.com",
"site": "http://buger.github.com",
"followers": 41,
"avatar": "https://d1qb2nb5cznatu.cloudfront.net/users/61541-medium_jpg?1405474390"
},
"klout": {
"handle": null,
"score": null
},
"foursquare": {
"handle": null
},
"aboutme": {
"handle": "leonid.bugaev",
"bio": null,
"avatar": null
},
"gravatar": {
"handle": "buger",
"urls": [
],
"avatar": "http://1.gravatar.com/avatar/f7c8edd577d13b8930d5522f28123510",
"avatars": [
{
"url": "http://1.gravatar.com/avatar/f7c8edd577d13b8930d5522f28123510",
"type": "thumbnail"
}
]
},
"fuzzy": false
},
"company": null
}
49 changes: 49 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/compare_to_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub fn values_equal(jiter_value: &JiterValue, serde_value: &SerdeValue) -> bool
if a1.len() != a2.len() {
return false;
}
for (v1, v2) in a1.into_iter().zip(a2.into_iter()) {
if !values_equal(v1, v2) {
for (v1, v2) in a1.iter().zip(a2.into_iter()) {
if !values_equal(&v1, v2) {
return false;
}
}
Expand All @@ -29,9 +29,9 @@ pub fn values_equal(jiter_value: &JiterValue, serde_value: &SerdeValue) -> bool
if o1.len() != o2.len() {
return false;
}
for (k1, v1) in o1.into_iter() {
for (k1, v1) in o1.iter_unique() {
if let Some(v2) = o2.get(k1) {
if !values_equal(&v1, v2) {
if !values_equal(v1, v2) {
return false;
}
} else {
Expand Down
Loading

0 comments on commit e9a4341

Please sign in to comment.