From 46cf096c3d2db239d4cb1252be5e13aaf22c0e81 Mon Sep 17 00:00:00 2001 From: Paul Millar Date: Wed, 23 May 2018 10:29:59 +0200 Subject: [PATCH] Add --no-container option 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. --- mdbench.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mdbench.py b/mdbench.py index e6ac301..5b8b3e4 100755 --- a/mdbench.py +++ b/mdbench.py @@ -19,6 +19,7 @@ -d, --dirs : number of generated directories to generate -s, --size : 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..' directory -h, --help : help message and PATH points to the directory where tests should run. Current directory @@ -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() @@ -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() @@ -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) @@ -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()