diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2015-08-24 16:25:09 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2015-08-24 16:25:09 -0400 |
commit | dd9f40ddc1ce8081b0cbbdd97d7a07d1a28baae9 (patch) | |
tree | 9a6b2c84a5c5bac217375b2ac39a47e07301d306 /examples | |
parent | a65f9a243292b0b0a2b4663ced3738a12ea51c14 (diff) | |
parent | 957daed3f7b46180f35127d6e0fc02b2ccfbb83a (diff) | |
download | mongo-dd9f40ddc1ce8081b0cbbdd97d7a07d1a28baae9.tar.gz |
Merge branch 'develop' into log-slot-revamp
Conflicts:
dist/s_define.list
src/include/log.h
src/include/stat.h
src/include/wiredtiger.in
src/log/log_slot.c
src/support/stat.c
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() |