Benchee v0.11.0 Benchee.Utility.FileCreation View Source

Methods to create files used in plugins.

Link to this section Summary

Functions

Open a file for write for all key/value pairs, interleaves the file name and calls function with file, content and filename

Gets file name/path, the input name and others together

Link to this section Functions

Link to this function each(names_to_content, filename, function \\ &default_each/3) View Source

Open a file for write for all key/value pairs, interleaves the file name and calls function with file, content and filename.

Uses Benchee.Utility.FileCreation.interlave/2 to get the base filename and the given keys together to one nice file name, then creates these files and calls the function with the file and the content from the given map so that data can be written to the file.

If a directory is specified, it creates the directory.

Expects:

  • names_to_content - a map from input name to contents that should go into the corresponding file
  • filename - the base file name as desired by the user
  • function - a function that is then called for every file with the associated file content from the map

Examples

# Just writes the contents to a file
Benchee.Utility.FileCreation.each(%{"My Input" => "_awesome html content_"},
  "my.html",
  fn(file, content) -> IO.write(file, content) end)
Link to this function interleave(filename, names) View Source

Gets file name/path, the input name and others together.

Takes a list of values to interleave or just a single value. Handles the special no_input key to do no work at all.

Examples

iex> Benchee.Utility.FileCreation.interleave("abc.csv", "hello")
"abc_hello.csv"

iex> Benchee.Utility.FileCreation.interleave("abc.csv", "Big Input")
"abc_big_input.csv"

iex> Benchee.Utility.FileCreation.interleave("bench/abc.csv", "Big Input")
"bench/abc_big_input.csv"

iex> Benchee.Utility.FileCreation.interleave("bench/abc.csv",
...>   ["Big Input"])
"bench/abc_big_input.csv"

iex> Benchee.Utility.FileCreation.interleave("abc.csv", [])
"abc.csv"

iex> Benchee.Utility.FileCreation.interleave("bench/abc.csv",
...>   ["Big Input", "Comparison"])
"bench/abc_big_input_comparison.csv"

iex> Benchee.Utility.FileCreation.interleave("bench/A B C.csv",
...>   ["Big Input", "Comparison"])
"bench/A B C_big_input_comparison.csv"

iex> Benchee.Utility.FileCreation.interleave("bench/abc.csv",
...>   ["Big Input", "Comparison", "great Stuff"])
"bench/abc_big_input_comparison_great_stuff.csv"

iex> marker = Benchee.Benchmark.no_input
iex> Benchee.Utility.FileCreation.interleave("abc.csv", marker)
"abc.csv"
iex> Benchee.Utility.FileCreation.interleave("abc.csv", [marker])
"abc.csv"
iex> Benchee.Utility.FileCreation.interleave("abc.csv",
...>   [marker, "Comparison"])
"abc_comparison.csv"
iex> Benchee.Utility.FileCreation.interleave("abc.csv",
...>   ["Something cool", marker, "Comparison"])
"abc_something_cool_comparison.csv"