"""util.py - General utilities for running, loading, and processing benchmarks
"""
# Input file type enumeration
= 0
= 1
= 2
= 2
"""
Return 'True' if 'filename' names a valid file which is likely
an executable. A file is considered an executable if it starts with the
magic bytes for a EXE, Mach O, or ELF file.
"""
return False
=
return in
:
return == b
return == b
"""
Returns 'True' if 'filename' names a valid JSON output file.
'False' otherwise.
"""
return True
pass
return False
"""
Return a tuple (type, msg) where 'type' specifies the classified type
of 'filename'. If 'type' is 'IT_Invalid' then 'msg' is a human readable
string represeting the error.
"""
=
= None
= %
not :
= %
:
=
:
=
= %
return ,
"""
Classify the file named by 'filename' and return the classification.
If the file is classified as 'IT_Invalid' print an error message and exit
the program.
"""
, =
return
"""
Search the specified list of flags for a flag matching `<prefix><arg>` and
if it is found return the arg it specifies. If specified more than once the
last value is returned. If the flag is not found None is returned.
"""
assert and
= None
=
return
"""
Return a new list containing the specified benchmark_flags except those
with the specified prefix.
"""
assert and
return
"""
Read benchmark output from a file and return the JSON object.
REQUIRES: 'fname' names a file containing JSON benchmark output.
"""
return
=
# From inner key to the outer key!
=
=
=
=
=
return
"""
Run a benchmark specified by 'exe_name' with the specified
'benchmark_flags'. The benchmark is run directly as a subprocess to preserve
real time console output.
RETURNS: A JSON object representing the benchmark output
"""
=
= False
= True
, =
= + \
= +
=
=
return
"""
Get the results for a specified benchmark. If 'filename' specifies
an executable benchmark then the results are generated by running the
benchmark. Otherwise 'filename' must name a valid JSON output file,
which is loaded and the result returned.
"""
=
return
return