baupaola

baupaola

Using fprof with unit test - getting FunctionClauseError

Hi, I need profile a slow my function test in suite test.
I used the suggestion of Bryan Stearns (https://selfamusementpark.com/profiling-a-slow-elixir-test)
but it does not work if I have variable or function outside the scope.
My hex version is

System.version
"1.6.4"

I tried iex -S mix profile.fprof --no-compile -e “Mix.Tasks.Test.run([])”, it work but the out is for all my test.
I need profile a single test , i tried iex -S mix profile.fprof --no-compile -e “Mix.Tasks.Test.run([only: "test/test_only_profile_trest.exs"])”

but the output is:

Erlang/OTP 20 [erts-9.3.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

07:53:28.841 application=router module=Router function=start_link/1 [info]  started ... with opts [name: RouterGenServer]
07:53:28.841 application=router module=Router function=init/1 [debug] init Elixir.Router with args -->[]
Warmup...
warning: variable "x" is unused
  test/support/helper.exs:37

warning: variable "tdiff" is unused
  test/support/helper.exs:46

** (FunctionClauseError) no function clause matching in String.split/3    
    
    The following arguments were given to **String.split/3:**
    
        # 1
        {:only, "test/test_only_profile_trest.exs"}
    
        # 2
        ":"
    
        # 3
        []
    
    Attempted function clauses (showing 4 out of 4):
    
        def split(string, %Regex{} = pattern, options) when is_binary(string)
        def split(string, "", options) when is_binary(string)
        def split(string, pattern, []) when is_tuple(pattern) or is_binary(string)
        def split(string, pattern, options) when is_binary(string)
    
    (elixir) lib/string.ex:383: String.split/3
    (ex_unit) lib/ex_unit/filters.ex:17: ExUnit.Filters.parse_path/1
    (mix) lib/mix/tasks/test.ex:338: Mix.Tasks.Test.parse_files/2
    (mix) lib/mix/tasks/test.ex:260: Mix.Tasks.Test.run/1
    (mix) lib/mix/tasks/profile.fprof.ex:167: Mix.Tasks.Profile.Fprof.profile_and_analyse/2
    (mix) lib/mix/tasks/profile.fprof.ex:160: Mix.Tasks.Profile.Fprof.profile/2

My mistake where is?
The key “only” is true for task test.

Thanks in advance.
Paola.

Most Liked

NobbZ

NobbZ

I’m not sure how exactly you write the command into the terminal.

Therefore please try these exact commands (copy and paste) and then show us the full transcript when they fail and properly wrap everything into a codeblock, not only the output, but also the command.

iex -S mix profile.fprof --no-compile -e 'Mix.Tasks.Test.run(["test/router_only_profile_test.exs"])'
iex -S mix profile.fprof --no-compile -e 'Mix.Tasks.Test.run(["--only", "test/router_only_profile_test.exs"])'
NobbZ

NobbZ

You need to specify the list of arguments as if you were giving it at the command line:

Mix.Tasks.Test.run(["--only", "test/test_only_profile_trest.exs"])

Aside of that, --only filters based on @tags, you probably want to pass only the file to run tests from:

Mix.Tasks.Test.run(["test/test_only_profile_trest.exs"])

Finally, I do think you have a typo in the filename :wink:

Last Post!

baupaola

baupaola

Thank you very much for your help, the error was double quotes after -e.
Now work.
Thank.
Paola.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
alice
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

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
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
sergio_101
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
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
romenigld
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

We're in Beta

About us Mission Statement