File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 3
3
4
4
ex = Exercizer ()
5
5
6
- ex .makeRandomBinFiles (numFiles = 25 , minSizekb = 1 ,
7
- maxSizekb = 101 , outDir = sys .argv [1 ] )
8
- ex .makeRandomBinFiles (numFiles = 20 , minSizekb = 200 ,
9
- maxSizekb = 10001 , outDir = sys .argv [1 ])
6
+ ex .makeRandomBinFiles (numFiles = 50 , minSizekb = 1 ,
7
+ maxSizekb = 101 , outDir = sys .argv [1 ], fnPrefix = sys . argv [ 2 ] )
8
+ ex .makeRandomBinFiles (numFiles = 40 , minSizekb = 200 ,
9
+ maxSizekb = 10001 , outDir = sys .argv [1 ], fnPrefix = sys . argv [ 2 ] )
10
10
ex .makeRandomBinFiles (numFiles = 10 , minSizekb = 20000 ,
11
- maxSizekb = 100001 , outDir = sys .argv [1 ])
11
+ maxSizekb = 100001 , outDir = sys .argv [1 ], fnPrefix = sys .argv [2 ])
12
+
13
+
Original file line number Diff line number Diff line change 14
14
15
15
import os , time
16
16
from os .path import join , getsize ,exists
17
+ from traceback import format_exc
17
18
class Exercizer (object ):
18
19
def __init__ (self ):
19
20
self .resetTimer ()
@@ -22,15 +23,16 @@ def makeRandomBinFiles (self,
22
23
outDir = '/tmp/smalldir' ,
23
24
numFiles = 10 ,
24
25
minSizekb = 1 ,
25
- maxSizekb = 1000001 ):
26
+ maxSizekb = 1000001 ,
27
+ fnPrefix = 'file_' ):
26
28
27
29
if not exists (outDir ):
28
30
os .makedirs (outDir )
29
31
ctr = 1
30
32
while ctr <= numFiles :
31
33
try :
32
34
fileSize = max ( 1 , ctr * (maxSizekb - minSizekb )/ numFiles )
33
- with open (join (outDir ,'file_' + str (fileSize )), 'wb' ) as fout :
35
+ with open (join (outDir ,fnPrefix + str (fileSize )), 'wb' ) as fout :
34
36
fout .write (os .urandom (fileSize * 1000 ))
35
37
ctr = ctr + 1
36
38
except :
You can’t perform that action at this time.
0 commit comments