Kaweeda
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 ->
StreamData.one_of([
# A JSON array
list_of(child_gen),
# A JSON object. Only supports string keys.
map_of(string(:printable), child_gen)
])
end)
# 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
IO.inspect(map_a)
assert map_b == js_patch(map_a, JsonDiffEx.diff(map_a, map_b))
on_exit(fn ->
:os.cmd('rm tmp/*.msgpack')
First Post!
dimitarvp
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.
Popular in Questions
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
I have a list say
x = ["23gh", "56kh", "97mh"]
I would like to pass each element to Val in each iteration.
Say, in iteration 1 -------...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New







