This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Iroha build time graph per each g++ target
Signed-off-by: Alexey Rodionov <[email protected]>
- Loading branch information
Showing
19 changed files
with
291 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# | ||
# Analyzes build time per each iroha build target (g++ target) and stores all results to csv-file: | ||
# target, work_type, sys_time, user_time, total, sys_time_diff, user_time_diff, total_diff, sys_time_perc, user_time_perc, total_perc | ||
# | ||
|
||
import csv | ||
from sys import argv | ||
from os import path | ||
|
||
F1, F2 = argv[1], argv[2] # base, compare | ||
|
||
# time difference in seconds (multiply by -1 show difference - faster or lower) | ||
def diff_secs(a, b): | ||
return round( (float(a) - float(b)) * -1 , 2) | ||
|
||
# time difference in percents (multiply by -1 show difference - faster or lower) | ||
def diff_perc(a, b): | ||
if float(a) == 0.0: | ||
return 0.0 | ||
return round( (float(a) - float(b)) / float(a) * 100 * -1, 2) | ||
|
||
if __name__ == '__main__': | ||
if not path.isfile(F1) or not path.isfile(F2): | ||
print("Can't find files!") | ||
exit(1) | ||
|
||
with open(F1) as base, open(F2) as compare: | ||
base_reader, comp_reader = csv.DictReader(base), csv.DictReader(compare) | ||
b, c = { row['target']: row for row in base_reader }, { row['target']: row for row in comp_reader } | ||
|
||
if len(c) == 0: | ||
print("No records found") | ||
exit(1) | ||
|
||
for target in c: | ||
c[target].update( | ||
{ 'user_time_diff': 0, 'sys_time_diff': 0, 'total_diff': 0, | ||
'user_time_perc': 0, 'sys_time_perc': 0, 'total_perc': 0 } | ||
) | ||
if b[target] is None: | ||
continue | ||
c[target]['sys_time_diff'] = diff_secs(b[target]['sys_time'], c[target]['sys_time']) | ||
c[target]['user_time_diff'] = diff_secs(b[target]['user_time'], c[target]['user_time']) | ||
c[target]['total_diff'] = diff_secs(b[target]['total'], c[target]['total']) | ||
c[target]['sys_time_perc'] = diff_perc(b[target]['sys_time'], c[target]['sys_time']) | ||
c[target]['user_time_perc'] = diff_perc(b[target]['user_time'], c[target]['user_time']) | ||
c[target]['total_perc'] = diff_perc(b[target]['total'], c[target]['total']) | ||
|
||
with open ('diff.csv', 'w+') as csvfile: | ||
fieldnames = ['target', 'work_type', | ||
'sys_time', 'user_time', 'total', | ||
'sys_time_diff', 'user_time_diff', 'total_diff', | ||
'sys_time_perc', 'user_time_perc', 'total_perc' | ||
] | ||
# fieldnames = sorted(next(iter(c.iteritems()))[1].keys()) | ||
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | ||
writer.writeheader() | ||
for row in c: | ||
writer.writerow(c[row]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" clang++-6.0 "${@}" 2> >(cat <(echo "clang++-6.0 ${@}") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" clang++-7 "${@}" 2> >(cat <(echo "clang++-7 ${@}") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" clang++ "${@}" 2> >(cat <(echo "clang++ ${@}") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" g++-5 "${@}" 2> >(cat <(echo "g++-5 ${@}") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" g++-7 "${@}" 2> >(cat <(echo "g++-7 ${@}") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# | ||
# Compares 2 csv files with build time data, makes new file with difference in seconds and percents | ||
# | ||
|
||
import re | ||
import argparse | ||
import csv | ||
|
||
parser = argparse.ArgumentParser(description='Process time output for compiler') | ||
|
||
parser.add_argument('log_file', type=str, help='input file') | ||
|
||
args = parser.parse_args() | ||
if __name__ == "__main__": | ||
lines = [] | ||
with open(args.log_file, "r") as f: | ||
lines = f.readlines() | ||
i = 0 | ||
units = [] | ||
while i < len(lines): | ||
unit = {} | ||
if "g++" not in lines[i]: | ||
i+=1 | ||
continue | ||
try: | ||
sys_time, user_time = lines[i+1].rstrip().split("\t") | ||
unit['target'] = re.findall(r"-o (\S+) ", lines[i])[0] | ||
unit['work_type'] = 'linking' if "-Wl" in lines[i] else "build" | ||
unit['sys_time'] = float(sys_time) | ||
unit['user_time'] = float(user_time) | ||
unit['total'] = round(unit['sys_time'] + unit['user_time'], 2) | ||
units.append(unit) | ||
i+=2 | ||
except: | ||
i+=1 | ||
continue | ||
|
||
csv_filename = args.log_file.split(".")[0] + ".csv" | ||
with open(csv_filename, 'w') as csvfile: | ||
fieldnames = ['target', 'sys_time', 'user_time', 'total', 'work_type'] | ||
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | ||
writer.writeheader() | ||
writer.writerows(units) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# | ||
# Analyzes build time per each iroha build target (g++ target) and stores all results to csv-file: | ||
# target, work_type, sys_time, user_time, total, sys_time_diff, user_time_diff, total_diff, sys_time_perc, user_time_perc, total_perc | ||
# | ||
|
||
import csv | ||
from sys import argv | ||
from os import path | ||
|
||
F1, F2 = argv[1], argv[2] # base, compare | ||
|
||
# time difference in seconds (multiply by -1 show difference - faster or lower) | ||
def diff_secs(a, b): | ||
return round( (float(a) - float(b)) * -1 , 2) | ||
|
||
# time difference in percents (multiply by -1 show difference - faster or lower) | ||
def diff_perc(a, b): | ||
if float(a) == 0.0: | ||
return 0.0 | ||
return round( (float(a) - float(b)) / float(a) * 100 * -1, 2) | ||
|
||
if __name__ == '__main__': | ||
if not path.isfile(F1) or not path.isfile(F2): | ||
print("Can't find files!") | ||
exit(1) | ||
|
||
with open(F1) as base, open(F2) as compare: | ||
base_reader, comp_reader = csv.DictReader(base), csv.DictReader(compare) | ||
b, c = { row['target']: row for row in base_reader }, { row['target']: row for row in comp_reader } | ||
|
||
if len(c) == 0: | ||
print("No records found") | ||
exit(1) | ||
|
||
for target in c: | ||
c[target].update( | ||
{ 'user_time_diff': 0, 'sys_time_diff': 0, 'total_diff': 0, | ||
'user_time_perc': 0, 'sys_time_perc': 0, 'total_perc': 0 } | ||
) | ||
if b[target] is None: | ||
continue | ||
c[target]['sys_time_diff'] = diff_secs(b[target]['sys_time'], c[target]['sys_time']) | ||
c[target]['user_time_diff'] = diff_secs(b[target]['user_time'], c[target]['user_time']) | ||
c[target]['total_diff'] = diff_secs(b[target]['total'], c[target]['total']) | ||
c[target]['sys_time_perc'] = diff_perc(b[target]['sys_time'], c[target]['sys_time']) | ||
c[target]['user_time_perc'] = diff_perc(b[target]['user_time'], c[target]['user_time']) | ||
c[target]['total_perc'] = diff_perc(b[target]['total'], c[target]['total']) | ||
|
||
with open ('diff.csv', 'w+') as csvfile: | ||
fieldnames = ['target', 'work_type', | ||
'sys_time', 'user_time', 'total', | ||
'sys_time_diff', 'user_time_diff', 'total_diff', | ||
'sys_time_perc', 'user_time_perc', 'total_perc' | ||
] | ||
# fieldnames = sorted(next(iter(c.iteritems()))[1].keys()) | ||
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | ||
writer.writeheader() | ||
for row in c: | ||
writer.writerow(c[row]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" g++ "$@" 2> >(cat <(echo "g++ $@") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
( /usr/bin/time -f "%S\t%U" g++ "$@" 2> >(cat <(echo "g++ $@") - )) | sponge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# | ||
# Compares 2 csv files with build time data, makes new file with difference in seconds and percents | ||
# | ||
|
||
import re | ||
import argparse | ||
import csv | ||
|
||
parser = argparse.ArgumentParser(description='Process time output for compiler') | ||
|
||
parser.add_argument('log_file', type=str, help='input file') | ||
|
||
args = parser.parse_args() | ||
if __name__ == "__main__": | ||
lines = [] | ||
with open(args.log_file, "r") as f: | ||
lines = f.readlines() | ||
i = 0 | ||
units = [] | ||
while i < len(lines): | ||
unit = {} | ||
if "g++" not in lines[i]: | ||
i+=1 | ||
continue | ||
try: | ||
sys_time, user_time = lines[i+1].rstrip().split("\t") | ||
unit['target'] = re.findall(r"-o (\S+) ", lines[i])[0] | ||
unit['work_type'] = 'linking' if "-Wl" in lines[i] else "build" | ||
unit['sys_time'] = float(sys_time) | ||
unit['user_time'] = float(user_time) | ||
unit['total'] = round(unit['sys_time'] + unit['user_time'], 2) | ||
units.append(unit) | ||
i+=2 | ||
except: | ||
i+=1 | ||
continue | ||
|
||
csv_filename = args.log_file.split(".")[0] + ".csv" | ||
with open(csv_filename, 'w') as csvfile: | ||
fieldnames = ['target', 'sys_time', 'user_time', 'total', 'work_type'] | ||
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | ||
writer.writeheader() | ||
writer.writerows(units) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters