Subject | Hash | Author | Date (UTC) |
---|---|---|---|
added profiling option to start script | 634b3664b6b694303fb9787781e074432967ead5 | mcehlert | 2014-02-24 15:45:06 |
added usage to readme | 8125b1f4f8cb59d96c8444accab88d77bf6dd42a | mcehlert | 2014-01-09 16:02:47 |
a lot of refactoring for more modular structure | 660e0d15e9b18aa9c1100c874e2140220f1c5860 | mcehlert | 2014-01-09 15:51:02 |
a lot of refactoring for more modular structure | dcf7bd73ccc2f871ab8d48c43d11a8e5b392b6de | mcehlert | 2014-01-09 15:50:53 |
initial commit - pre colloquim state | 655c77556f9d8e40b52893887cdb0d90f726fdbf | Mathias Ehlert | 2013-11-22 13:47:29 |
Initial commit | f53ec7a3f25d55c53aa12c2682b216e16570cdc7 | Mathias Ehlert | 2013-11-22 13:37:47 |
File | Lines added | Lines deleted |
---|---|---|
start.py | 16 | 0 |
File start.py changed (mode: 100644) (index 29e5255..434481f) | |||
1 | 1 | #!/usr/bin/env python | #!/usr/bin/env python |
2 | import datetime | ||
2 | 3 | import argparse | import argparse |
4 | import cProfile, pstats, StringIO | ||
3 | 5 | from file_importer import FileImporter | from file_importer import FileImporter |
4 | 6 | from metric_calculator import MetricCalculator | from metric_calculator import MetricCalculator |
5 | 7 | ||
... | ... | parser = argparse.ArgumentParser(description='Read a Tab-separated Graph Datafil | |
8 | 10 | parser.add_argument('filename', metavar='filename', type=str, | parser.add_argument('filename', metavar='filename', type=str, |
9 | 11 | help='the name of the data file containing tab separated node ids') | help='the name of the data file containing tab separated node ids') |
10 | 12 | ||
13 | parser.add_argument('--profiling',dest='profiling',action='store_true', help='enable runtime profiling into profiling.txt file') | ||
14 | |||
11 | 15 | args = parser.parse_args() | args = parser.parse_args() |
12 | 16 | ||
17 | if args.profiling: | ||
18 | pr = cProfile.Profile() | ||
19 | s = StringIO.StringIO() | ||
20 | timestamp = str(datetime.datetime.now().strftime('%Y%m%d%H%M%S')) | ||
21 | outfile = open('profiling_output_'+timestamp+'.txt', 'w') | ||
22 | pr.enable() | ||
23 | |||
13 | 24 | fi = FileImporter(args.filename) | fi = FileImporter(args.filename) |
14 | 25 | graph = fi.read() | graph = fi.read() |
15 | 26 | mc = MetricCalculator(graph) | mc = MetricCalculator(graph) |
16 | 27 | mc.start() | mc.start() |
28 | |||
29 | if args.profiling: | ||
30 | ps = pstats.Stats(pr, stream=s).sort_stats('cumulative') | ||
31 | ps.print_stats() | ||
32 | outfile.write(s.getvalue()) |