~ubuntu-branches/ubuntu/wily/xmms2/wily

« back to all changes in this revision

Viewing changes to wafadmin/test/stress.tst

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2008-05-29 10:14:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080529101425-ycw1nbd980uhvzfp
Tags: 0.4DrKosmos-4ubuntu1
* Merge from debian unstable (LP: #178477), remaining changes:
  - debian/control: Update Maintainer field
  - debian/control: add lpia to xmms2-plugin-alsa supported architectures
* This version reads AAC files (LP: #156359)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
 
3
 
# loading an environment
4
 
 
5
 
import Params
6
 
import Runner
7
 
pexec = Runner.exec_command
8
 
 
9
 
Params.set_trace(0, 0, 0)
10
 
 
11
 
# constants
12
 
sconstruct_x = """
13
 
bld.set_srcdir('.')
14
 
bld.set_bdir('_build_')
15
 
bld.scandirs('src ')
16
 
from Common import dummy
17
 
add_subdir('src')
18
 
"""
19
 
 
20
 
sconscript_0="""
21
 
obj=dummy()
22
 
obj.source='dummy.h'
23
 
obj.target='dummy.i'
24
 
"""
25
 
 
26
 
sconscript_1="""
27
 
i=0
28
 
while i<1000:
29
 
        i+=1
30
 
        obj=dummy()
31
 
        obj.source='dummy.h'
32
 
        obj.target='dummy.i'
33
 
"""
34
 
 
35
 
sconscript_2="""
36
 
i=0
37
 
while i<10000:
38
 
        i+=1
39
 
        obj=dummy()
40
 
        obj.source='dummy.h'
41
 
        obj.target='dummy.i'
42
 
"""
43
 
 
44
 
def runscript(scriptname):
45
 
        # clean before building
46
 
        pexec('rm -rf runtest/ && mkdir -p runtest/src/')
47
 
 
48
 
        # write our files
49
 
        dest = open('./runtest/sconstruct', 'w')
50
 
        dest.write(sconstruct_x)
51
 
        dest.close()
52
 
 
53
 
        dest = open('./runtest/src/sconscript', 'w')
54
 
        dest.write(scriptname)
55
 
        dest.close()
56
 
 
57
 
        dest = open('./runtest/src/dummy.h', 'w')
58
 
        dest.write('content')
59
 
        dest.close()
60
 
 
61
 
        # now that the files are there, run the app
62
 
        Params.set_trace(0,0,0)
63
 
 
64
 
        os.chdir('runtest')
65
 
        sys.path.append('..')
66
 
        import Scripting
67
 
 
68
 
        import time
69
 
        t1=time.clock()
70
 
        Scripting.Main()
71
 
        t2=time.clock()
72
 
 
73
 
        os.chdir('..')
74
 
        Params.set_trace(1,1,1)
75
 
 
76
 
        return (t2-t1)
77
 
 
78
 
#t=runscript(sconscript_1)
79
 
#print "* posting 1000  objects ",t," seconds (1000  times the same)"
80
 
#t=runscript(sconscript_2)
81
 
#print "* posting 10000 objects ",t," seconds (10000 times the same)"
82
 
 
83
 
 
84
 
def runscript2(scriptname, howmany):
85
 
        # clean before building
86
 
        pexec('rm -rf runtest/ && mkdir -p runtest/src/')
87
 
 
88
 
        sc = open('./runtest/sconstruct', 'w')
89
 
        sc.write("""
90
 
bld.set_srcdir('.')
91
 
bld.set_bdir('_build_')
92
 
bld.scandirs('""")
93
 
 
94
 
        i=0
95
 
        while i<howmany:
96
 
                if i<1: sc.write('src'+str(i))
97
 
                else: sc.write(' src'+str(i))
98
 
                i+=1
99
 
 
100
 
        sc.write("""')
101
 
from Common import dummy
102
 
""")
103
 
 
104
 
        i=0
105
 
        while i<howmany:
106
 
                sc.write('add_subdir("src'+str(i)+'")\n')
107
 
                i+=1
108
 
 
109
 
        sc.write("""
110
 
import Params
111
 
#Params.set_trace(0,0,0)""")
112
 
        sc.close()
113
 
 
114
 
        # write our files
115
 
        i=0
116
 
        while i<howmany:
117
 
                pexec('mkdir -p runtest/src'+str(i))
118
 
 
119
 
                dest = open('./runtest/src'+str(i)+'/sconscript', 'w')
120
 
                dest.write(scriptname)
121
 
                dest.close()
122
 
 
123
 
                dest = open('./runtest/src'+str(i)+'/dummy.h', 'w')
124
 
                dest.write('content')
125
 
                dest.close()
126
 
                i+=1
127
 
 
128
 
        # now that the files are there, run the app
129
 
        
130
 
        #Params.set_trace(0,0,0)
131
 
 
132
 
def measure():
133
 
        os.chdir('runtest')
134
 
        sys.path.append('..')
135
 
        import Scripting
136
 
 
137
 
        import time
138
 
        t1=time.clock()
139
 
        Scripting.Main()
140
 
        t2=time.clock()
141
 
 
142
 
        os.chdir('..')
143
 
        
144
 
        return (t2-t1)
145
 
 
146
 
val=750
147
 
runscript2(sconscript_0, val)
148
 
t=measure()
149
 
print "* posted %d objects in %.2f seconds (%d different ones)" % (val, t, val)
150
 
 
151
 
import Utils
152
 
 
153
 
Utils.reset()
154
 
t=measure()
155
 
print "* posted %d objects in %.2f seconds (%d different ones, second run)" % (val, t, val)
156
 
 
157
 
Utils.reset()
158
 
t=measure()
159
 
print "* posted %d objects in %.2f seconds (%d different ones, third run)" % (val, t, val)
160
 
 
161
 
 
162
 
# cleanup
163
 
info("stress test end")
164
 
#pexec('rm -rf runtest/')
165