gcpy.benchmark.modules.benchmark_scrape_gchp_timers

Scrapes GCHP Classic benchmark timing information from one or more text files.

Functions

check_file_for_timing_info(text_file)

Checks if a given text file contains GCHP timers output.

count_characters(text[, char_to_match])

Returns the number of characters in a string of text.

display_timers(ref, ref_label, dev, ...)

Prints the GCHP timer information to a table.

make_benchmark_gchp_timing_table(ref_files, ...)

Creates a table of timing information for GCHP benchmark simulations given one or more text files as input.

print_timer(key, ref, dev, ofile)

Prints timing info for a single timer to a log file.

read_one_text_file(text_file)

Parses the GCHP log file (plain text) with timing information and returns a dictionary with the results.

read_timing_data(input_files)

Parses the GEOS-Chem Classic timing information in JSON format and returns a dictionary with the results.

sum_timers(timers)

Sums the time in seconds for each GEOS-Chem timer.

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.read_timing_data(input_files)[source]

Parses the GEOS-Chem Classic timing information in JSON format and returns a dictionary with the results.

Parameters:

input_files (str or list) – Text file(s) to parse.

Returns:

timing – Dictionary with timing information.

Return type:

list of dict

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.count_characters(text, char_to_match='.')[source]

Returns the number of characters in a string of text.

Parameters:
  • text (str) – The text to parse.

  • char_to_match (str, optional) – The character to look for in text.

Returns:

result – Number of occurrences of char_to_match in text.

Return type:

int

References

https://stackoverflow.com/questions/991350/counting-repeated-characters-in-a-string-in-python

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.check_file_for_timing_info(text_file)[source]

Checks if a given text file contains GCHP timers output. If not, we will reset the file name to allPEs.log (in the same path).

This update is necessary because MAPL v2.59 has switched the GCHP timers printout from the GCHP log file to allPEs.log. This will allow backwards compatibility with output from GCHP simulations that use older MAPL versions.

Parameters:

text_file (str) – Name of the text file to check.

Returns:

text_file – Name of the text file containing GCHP timers output (either the input file or “allPEs.log”).

Return type:

str

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.read_one_text_file(text_file)[source]

Parses the GCHP log file (plain text) with timing information and returns a dictionary with the results.

Parameters:

text_file (str) – Text file with timing information.

Returns:

timers – Dictionary with timing information.

Return type:

dict

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.sum_timers(timers)[source]

Sums the time in seconds for each GEOS-Chem timer. Input may be a single dict with timing information or a list of dicts.

Parameters:

timers (dict or list) – GCHP timing information from one or more log files in plain text format.

Returns:

result – Sum of timing information.

Return type:

dict

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.print_timer(key, ref, dev, ofile)[source]

Prints timing info for a single timer to a log file.

Parameters:
  • key (str) – Dictionary key to print.

  • ref (dict) – Timing information from the “Ref” model.

  • dev (dict) – Timing information from the “Dev” model.

  • ofile (file) – File object where info will be written.

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.display_timers(ref, ref_label, dev, dev_label, table_file)[source]

Prints the GCHP timer information to a table.

Parameters:
  • ref (dict) – Timing information from the “Ref” model.

  • ref_label (str) – Version string for the “Ref” model.

  • dev (dict) – Timing information from the “Dev” model.

  • dev_label (str) – Version string for the “Dev” model.

  • table_file (str) – File name for the timing table output.

gcpy.benchmark.modules.benchmark_scrape_gchp_timers.make_benchmark_gchp_timing_table(ref_files, ref_label, dev_files, dev_label, dst='./benchmark', overwrite=False)[source]

Creates a table of timing information for GCHP benchmark simulations given one or more text files as input.

Parameters:
  • ref_files (str or list) – File(s) with timing info from the “Ref” model.

  • ref_label (str) – Version string for the “Ref” model.

  • dev_files (str or list) – File(s) with timing info from the “Dev” model.

  • dev_label (str) – Version string for the “Dev” model.

  • dst (str, optional) – Directory where output will be written.

  • overwrite (bool, optional) – Overwrite existing files? Default: False.