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
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
can someone please explain to me how Enum.reduce works with maps
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lists...
New
How to bind a phoenix app to a specific ip address?
could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Other popular topics
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









