[
{ "op": "test", "path": "/baz", "value": "qux" },
{ "op": "test", "path": "/foo/1", "value": 2 },
# repeated to get an ~28 MB file
]
Moving [Array, Hash, Set] to the class and/or making it a Set/Hash yields no measurable improvement for this workload. It's also not faster to define different methods for the dup/non-dup cases.
Also, I'm not sure that class.new actually saves any time, since it's so close to the other result. I'd have to do more testing and proper statistics. I can change that back to .dup if desired.
The speedup mostly comes from moving repeated work out of the custom attribute reader into
attr_copyable
and only doing it once.Timings:
Using Ruby 2.5 with
bin/validate-schema schema.json data.json
, so includes parsing.Schema used: https://github.com/fge/sample-json-schemas/blob/master/json-patch/json-patch.json sample data:
Moving
[Array, Hash, Set]
to the class and/or making it a Set/Hash yields no measurable improvement for this workload. It's also not faster to define different methods for the dup/non-dup cases.Also, I'm not sure that
class.new
actually saves any time, since it's so close to the other result. I'd have to do more testing and proper statistics. I can change that back to.dup
if desired.