Skip to content

Commit

Permalink
Add --no-container option
Browse files Browse the repository at this point in the history
Motivation:

If mdbench is run on a single node, the extra directory is unnecessary

Modification:

Add --no-container option to avoid creating the mdbench.x.y directory.

Default behaviour remains unchanged

Result:

Possible to avoid creating an unnecessary directory.
  • Loading branch information
paulmillar committed May 23, 2018
1 parent ca21271 commit 46cf096
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mdbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-d, --dirs <N> : number of generated directories to generate
-s, --size <N> : size of generated files in B/K/M/G
-n, --no-clean : do not delete created files and directories
--no-container : do not create the 'mdbench.<name>.<pid>' directory
-h, --help : help message
and PATH points to the directory where tests should run. Current directory
Expand Down Expand Up @@ -128,10 +129,11 @@ def main():
file_count = FILE_COUNT
file_size = FILE_SIZE
cleanup = True
createContainer = True

try:
options, remainder = getopt.gnu_getopt(sys.argv[1:], 'f:d:s:nh', \
['files=','dirs=','size=','no-clean','help'])
['files=','dirs=','size=','no-clean','no-container','help'])
except getopt.GetoptError as err:
print str(err)
usage()
Expand All @@ -145,6 +147,8 @@ def main():
file_size = get_size(arg)
elif opt in ('-n', '--no-clean'):
cleanup = False
elif opt in ('--no-container'):
createContainer = False
elif opt in ('-h', '--help'):
usage()

Expand All @@ -153,9 +157,11 @@ def main():

path = remainder[0]

root = '%s/mdbench.%s.%d' % (path, socket.gethostname(), os.getpid())
root = '%s/mdbench.%s.%d' % (path, socket.gethostname(), os.getpid()) if createContainer else path

if createContainer:
os.mkdir(root)

os.mkdir(root)
elapsed, result = bench_run( make_dirs, root, dir_count )
in_sec = total_seconds(elapsed)
print '%.2f dir creates per second' % (dir_count/in_sec)
Expand All @@ -177,7 +183,8 @@ def main():
in_sec = total_seconds(elapsed)
print '%.2f dir removes per second' % (dir_count/in_sec)

os.rmdir(root)
if createContainer:
os.rmdir(root)

if __name__ == '__main__':
main()

0 comments on commit 46cf096

Please sign in to comment.