File: prof.py

package info (click to toggle)
python-pyvcf 0.6.8%2Bgit20170215.476169c-11
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,872 kB
  • sloc: python: 2,921; makefile: 125
file content (33 lines) | stat: -rwxr-xr-x 712 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import vcf as vcf
import cProfile
import timeit
import pstats
import sys

def parse_1kg():
    for line in vcf.Reader(filename='vcf/test/1kg.vcf.gz'):
        pass

if len(sys.argv) == 1:
    sys.argv.append(None)

if sys.argv[1] == 'profile':
    cProfile.run('parse_1kg()', '1kg.prof')
    p = pstats.Stats('1kg.prof')
    p.strip_dirs().sort_stats('time').print_stats()

elif sys.argv[1] == 'time':
    n = 1
    t = timeit.timeit('parse_1kg()',  "from __main__ import parse_1kg", number=n)
    print(t/n)

elif sys.argv[1] == 'stat':
    import statprof
    statprof.start()
    try:
        parse_1kg()
    finally:
        statprof.stop()
        statprof.display()
else:
    print('prof.py profile/time')