diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-08-20 11:10:24 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-08-20 11:10:24 +1000 |
commit | 7f70a59df554a85a8506391a11e01d19007869b1 (patch) | |
tree | ac0aadd48e3beae22dfb29135eb8d733ed05d6e4 /examples | |
parent | 98b4a28e598eb70cc9aea28ea662bdb0b04372c1 (diff) | |
parent | cc4ad7f0cd58649f82c6c5e549f4a2fc4dcb0968 (diff) | |
download | mongo-7f70a59df554a85a8506391a11e01d19007869b1.tar.gz |
Merge branch 'master' into develop
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/python/ex_access.py | 2 | ||||
-rwxr-xr-x | examples/python/ex_stat.py | 30 |
2 files changed, 19 insertions, 13 deletions
diff --git a/examples/python/ex_access.py b/examples/python/ex_access.py index 8eeefd56cf7..2940ac63625 100755 --- a/examples/python/ex_access.py +++ b/examples/python/ex_access.py @@ -50,6 +50,6 @@ cursor.insert() # Iterate through the records cursor.reset() for key, value in cursor: - print('Got record: ' + key + ' : ' + value) + print('Got record: %s : %s' % (key, value)) conn.close() diff --git a/examples/python/ex_stat.py b/examples/python/ex_stat.py index e27177403cc..af2c4f7a1a7 100755 --- a/examples/python/ex_stat.py +++ b/examples/python/ex_stat.py @@ -32,6 +32,7 @@ import os from wiredtiger import wiredtiger_open,WIREDTIGER_VERSION_STRING,stat + def main(): # Create a clean test directory for this run of the test program os.system('rm -rf WT_HOME') @@ -39,16 +40,16 @@ def main(): # Connect to the database and open a session conn = wiredtiger_open('WT_HOME', 'create,statistics=(all)') session = conn.open_session() - + # Create a simple table session.create('table:access', 'key_format=S,value_format=S') - + # Open a cursor and insert a record cursor = session.open_cursor('table:access', None) - cursor['key'] = 'value' + cursor['key'] = 'value' cursor.close() - + session.checkpoint() print WIREDTIGER_VERSION_STRING print_database_stats(session) @@ -57,46 +58,51 @@ def main(): print_derived_stats(session) conn.close() + def print_database_stats(session): statcursor = session.open_cursor("statistics:") print_cursor(statcursor) statcursor.close() + def print_file_stats(session): fstatcursor = session.open_cursor("statistics:table:access") print_cursor(fstatcursor) fstatcursor.close() + def print_overflow_pages(session): ostatcursor = session.open_cursor("statistics:table:access") val = ostatcursor[stat.dsrc.btree_overflow] - if val != 0 : - print str(val[0]) + '=' + str(val[1]) + if val != 0: + print '%s=%s' % (str(val[0]), str(val[1])) ostatcursor.close() + def print_derived_stats(session): dstatcursor = session.open_cursor("statistics:table:access") ckpt_size = dstatcursor[stat.dsrc.block_checkpoint_size][1] file_size = dstatcursor[stat.dsrc.block_size][1] percent = 0 - if file_size != 0 : + if file_size != 0: percent = 100 * ((float(file_size) - float(ckpt_size)) / float(file_size)) - print "Table is %" + str(percent) + " fragmented" + print "Table is %%%s fragmented" % str(percent) app_insert = int(dstatcursor[stat.dsrc.cursor_insert_bytes][1]) app_remove = int(dstatcursor[stat.dsrc.cursor_remove_bytes][1]) app_update = int(dstatcursor[stat.dsrc.cursor_update_bytes][1]) - fs_writes = int(dstatcursor[stat.dsrc.cache_bytes_write][1]) + fs_writes = int(dstatcursor[stat.dsrc.cache_bytes_write][1]) - if(app_insert + app_remove + app_update != 0): + if app_insert + app_remove + app_update != 0: print "Write amplification is " + '{:.2f}'.format(fs_writes / (app_insert + app_remove + app_update)) dstatcursor.close() + def print_cursor(mycursor): while mycursor.next() == 0: val = mycursor.get_value() - if val[1] != '0' : - print str(val[0]) + '=' + str(val[1]) + if val[1] != '0': + print '%s=%s' % (str(val[0]), str(val[1])) if __name__ == "__main__": main() |