6"""Writes a Perf-formated json file with stats about the given web file."""
9from __future__
import print_function
17 input_file = sys.argv[1]
21 total_size_bytes_key = sys.argv[5]
22 magic_seperator = sys.argv[6]
29 props = propstr.split(
' ')
30 for i
in range(0,
len(props), 2):
31 results[props[i]] = props[i+1]
33 keys = keystr.split(
' ')
34 for i
in range(0,
len(keys), 2):
35 results[
'key'][keys[i]] = keys[i+1]
38 total_size_bytes_key: os.path.getsize(input_file)
43 temp_file = input_file +
'_tmp'
44 subprocess.check_call([
'cp', input_file, temp_file])
45 subprocess.check_call([
'gzip', temp_file])
47 r[
'gzip_size_bytes'] = os.path.getsize(temp_file +
'.gz')
49 name = os.path.basename(input_file)
51 print(magic_seperator)
52 results[
'results'][name] = {
60 print(json.dumps(results, indent=2))
62 with open(os.path.join(out_dir, name+
'.json'),
'w')
as output:
63 output.write(json.dumps(results, indent=2))
66if __name__ ==
'__main__':
def print(*args, **kwargs)