Slow Property test

Hi, so I have a property test where I am using a custom generator to generate nested Json objects. When my second test runs for larger objects, it takes quite some time or it’s inconsistent. Sometimes takes 10 seconds and sometimes takes 100 seconds +. Is there anyway to make this code more efficient? I am currently resizing them to test for smaller and larger Json objects, would using the function sized be more efficient. Thank you in advance, here is the code.

@tag timeout: :infinity
  property "when a & b are arbitrary large json objects; patch(a, diff(a,b)) == b" do
    primitive = one_of([string(:printable), integer()])

    json_fragment_gen =
      tree(primitive, fn child_gen ->
          # A JSON array
          # A JSON object. Only supports string keys.
          map_of(string(:printable), child_gen)

    # Only valid top-level JSON are objects and arrays
    json_gen = json_fragment_gen |> filter(fn val -> is_map(val) end, 100)

    check all(
            map_a <- resize(json_gen, 900),
            map_b <- resize(json_gen, 900),
            map_a != map_b,
            max_runs: 10
          ) do

      assert map_b == js_patch(map_a, JsonDiffEx.diff(map_a, map_b))

      on_exit(fn ->
        :os.cmd('rm tmp/*.msgpack')

That’s likely generating quite a huge set of potential values. Try reducing it e.g.:

string([?A..?Z, ?0..?9], min_length: 2, max_length: 6)

That’s where I’d start.