File: musicparser-test.py

package info (click to toggle)
solfege 2.0.4-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,200 kB
  • ctags: 1,844
  • sloc: python: 12,160; xml: 5,458; ansic: 1,486; makefile: 562; sh: 233
file content (54 lines) | stat: -rwxr-xr-x 1,285 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python2.2

import pygtk
pygtk.require("2.0")
import profile, os
import sys

if os.getcwd()[-4:] == "test":
   sys.path.append("..")
else:
   sys.path.append(".")

import mpd

music = r"""
\staff{ \time 4/4 r16 [c d e] [f d e c] [g'8 c] [b c] |
               [d16 g, a b] [c a b g] [d'8 g] [f g] |
               [e16 a g f] [e g f a] [g f e d] [c e d f] }
\staff{ \time 4/4 r2 r16 [c d e] [f d e c] |
                [g'8 g,] r4 r16 [g'16 a b] [c a b g] |
                [c8 b] [c d] [e g,] [a b] |
                }
"""
#music = r"""\staff{ c' d }"""
def vis():
        import pstats
        p = pstats.Stats("profile.txt")
        ##p.strip_dirs().sort_stats('time').print_stats(30)
        p.strip_dirs().sort_stats('cumulative').print_stats()


def pass1():
        for n in range(200):
                score = mpd.parser.parse_to_score_object(music)
                #eng = score.get_engravers(20)
def pass2():
    for x in range(20):
        score = mpd.parser.parse_to_score_object(music)
        eng = score.get_engravers(20)

import time
t1 = time.clock()
if 0:
    os.system("rm -f profile.txt")
    profile.run("pass2()", "profile.txt")
    vis()
else:
    #import gc
    #gc.set_debug(gc.DEBUG_LEAK)
    pass1()
    #gc.collect()
t2 = time.clock()
print t2-t1